[Lldb-commits] [lldb] 813ca53 - [lldb][NFC] Document TypeSystemClang

2020-02-18 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-02-18T09:00:03+01:00
New Revision: 813ca53fdea130a23e302ea2afecaa5134def6db

URL: 
https://github.com/llvm/llvm-project/commit/813ca53fdea130a23e302ea2afecaa5134def6db
DIFF: 
https://github.com/llvm/llvm-project/commit/813ca53fdea130a23e302ea2afecaa5134def6db.diff

LOG: [lldb][NFC] Document TypeSystemClang

Added: 


Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index 02382b587d67..dc9a10bd61a0 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -45,6 +45,16 @@ class ClangASTMetadata;
 class ClangASTSource;
 class Declaration;
 
+/// A TypeSystem implementation based on Clang.
+///
+/// This class uses a single clang::ASTContext as the backend for storing
+/// its types and declarations. Every clang::ASTContext should also just have
+/// a single associated TypeSystemClang instance that manages it.
+///
+/// The clang::ASTContext instance can either be created by TypeSystemClang
+/// itself or it can adopt an existing clang::ASTContext (for example, when
+/// it is necessary to provide a TypeSystem interface for an existing
+/// clang::ASTContext that was created by clang::CompilerInstance).
 class TypeSystemClang : public TypeSystem {
   // LLVM RTTI support
   static char ID;
@@ -114,6 +124,7 @@ class TypeSystemClang : public TypeSystem {
   /// purpose it serves in LLDB. Used for example in logs.
   llvm::StringRef getDisplayName() const { return m_display_name; }
 
+  /// Returns the clang::ASTContext instance managed by this TypeSystemClang.
   clang::ASTContext &getASTContext();
 
   clang::MangleContext *getMangleContext();
@@ -997,6 +1008,8 @@ class TypeSystemClang : public TypeSystem {
   void SetTargetTriple(llvm::StringRef target_triple);
 };
 
+/// The TypeSystemClang instance used for the scratch ASTContext in a
+/// lldb::Target.
 class TypeSystemClangForExpressions : public TypeSystemClang {
 public:
   TypeSystemClangForExpressions(Target &target, llvm::Triple triple);



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


[Lldb-commits] [PATCH] D74607: [lldb][NFC] Make all CompilerDeclContext parameters references instead of pointers

2020-02-18 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf9568a95493a: [lldb][NFC] Make all CompilerDeclContext 
parameters references instead of… (authored by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74607

Files:
  lldb/include/lldb/Core/Module.h
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/source/API/SBModule.cpp
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Core/AddressResolverName.cpp
  lldb/source/Core/Disassembler.cpp
  lldb/source/Core/Module.cpp
  lldb/source/Core/ModuleList.cpp
  lldb/source/Core/SourceManager.cpp
  lldb/source/Expression/IRExecutionUnit.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
  
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
  lldb/source/Symbol/SymbolFile.cpp
  lldb/tools/lldb-test/lldb-test.cpp

Index: lldb/tools/lldb-test/lldb-test.cpp
===
--- lldb/tools/lldb-test/lldb-test.cpp
+++ lldb/tools/lldb-test/lldb-test.cpp
@@ -395,7 +395,8 @@
   if (Context.empty())
 return CompilerDeclContext();
   VariableList List;
-  Symfile.FindGlobalVariables(ConstString(Context), nullptr, UINT32_MAX, List);
+  Symfile.FindGlobalVariables(ConstString(Context), CompilerDeclContext(),
+  UINT32_MAX, List);
   if (List.Empty())
 return make_string_error("Context search didn't find a match.");
   if (List.GetSize() > 1)
@@ -442,8 +443,8 @@
 Expected ContextOr = getDeclContext(Symfile);
 if (!ContextOr)
   return ContextOr.takeError();
-CompilerDeclContext *ContextPtr =
-ContextOr->IsValid() ? &*ContextOr : nullptr;
+const CompilerDeclContext &ContextPtr =
+ContextOr->IsValid() ? *ContextOr : CompilerDeclContext();
 
 List.Clear();
 Symfile.FindFunctions(ConstString(Name), ContextPtr, getFunctionNameFlags(),
@@ -498,8 +499,8 @@
   Expected ContextOr = getDeclContext(Symfile);
   if (!ContextOr)
 return ContextOr.takeError();
-  CompilerDeclContext *ContextPtr =
-  ContextOr->IsValid() ? &*ContextOr : nullptr;
+  const CompilerDeclContext &ContextPtr =
+  ContextOr->IsValid() ? *ContextOr : CompilerDeclContext();
 
   CompilerDeclContext Result =
   Symfile.FindNamespace(ConstString(Name), ContextPtr);
@@ -516,8 +517,8 @@
   Expected ContextOr = getDeclContext(Symfile);
   if (!ContextOr)
 return ContextOr.takeError();
-  CompilerDeclContext *ContextPtr =
-  ContextOr->IsValid() ? &*ContextOr : nullptr;
+  const CompilerDeclContext &ContextPtr =
+  ContextOr->IsValid() ? *ContextOr : CompilerDeclContext();
 
   LanguageSet languages;
   if (!Language.empty())
@@ -566,8 +567,8 @@
 Expected ContextOr = getDeclContext(Symfile);
 if (!ContextOr)
   return ContextOr.takeError();
-CompilerDeclContext *ContextPtr =
-ContextOr->IsValid() ? &*ContextOr : nullptr;
+const CompilerDeclContext &ContextPtr =
+ContextOr->IsValid() ? *ContextOr : CompilerDeclContext();
 
 Symfile.FindGlobalVariables(ConstString(Name), ContextPtr, UINT32_MAX, List);
   }
Index: lldb/source/Symbol/SymbolFile.cpp
===
--- lldb/source/Symbol/SymbolFile.cpp
+++ lldb/source/Symbol/SymbolFile.cpp
@@ -105,7 +105,7 @@
 }
 
 void SymbolFile::FindGlobalVariables(ConstString name,
- const CompilerDeclContext *parent_decl_ctx,
+ const CompilerDeclContext &parent_decl_ctx,
  uint32_t max_matches,
  VariableList &variables) {}
 
@@ -114,7 +114,7 @@
  VariableList &variables) {}
 
 void SymbolFile::FindFunctions(ConstString name,
-   const CompilerDeclContext *parent_decl_ctx,
+   const CompilerDeclConte

[Lldb-commits] [PATCH] D73067: [lldb/CMake] Auto-generate the Initialize and Terminate calls for plugin

2020-02-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7d6da329dee1: [lldb/CMake] Auto-generate the Initialize and 
Terminate calls for plugin (authored by JDevlieghere).
Herald added a subscriber: jrtc27.

Changed prior to commit:
  https://reviews.llvm.org/D73067?vs=244700&id=244990#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73067

Files:
  lldb/include/lldb/Core/PluginManager.h
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
  lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
  lldb/source/Plugins/ABI/ARM/ABIMacOSX_arm.cpp
  lldb/source/Plugins/ABI/Hexagon/ABISysV_hexagon.cpp
  lldb/source/Plugins/ABI/SystemZ/ABISysV_s390x.cpp
  lldb/source/Plugins/CMakeLists.txt
  lldb/source/Plugins/Disassembler/LLVMC/CMakeLists.txt
  lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/DynamicLoaderHexagonDYLD.cpp
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
  lldb/source/Plugins/Instruction/ARM64/EmulateInstructionARM64.cpp
  lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp
  lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp
  lldb/source/Plugins/Instruction/PPC64/EmulateInstructionPPC64.cpp
  lldb/source/Plugins/Language/ClangCommon/CMakeLists.txt
  lldb/source/Plugins/Language/ObjC/CMakeLists.txt
  lldb/source/Plugins/LanguageRuntime/CPlusPlus/CMakeLists.txt
  
lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/CMakeLists.txt
  
lldb/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
  lldb/source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp
  lldb/source/Plugins/OperatingSystem/CMakeLists.txt
  lldb/source/Plugins/Platform/POSIX/CMakeLists.txt
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Plugins/Plugins.def.in
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/source/Plugins/Process/Utility/CMakeLists.txt
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/UnwindAssembly/x86/UnwindAssembly-x86.cpp
  lldb/tools/lldb-test/CMakeLists.txt
  lldb/tools/lldb-test/SystemInitializerTest.cpp
  lldb/unittests/Disassembler/CMakeLists.txt
  lldb/unittests/UnwindAssembly/ARM64/CMakeLists.txt
  lldb/unittests/UnwindAssembly/PPC64/CMakeLists.txt

Index: lldb/unittests/UnwindAssembly/PPC64/CMakeLists.txt
===
--- lldb/unittests/UnwindAssembly/PPC64/CMakeLists.txt
+++ lldb/unittests/UnwindAssembly/PPC64/CMakeLists.txt
@@ -5,7 +5,7 @@
 lldbSymbol
 lldbTarget
 lldbPluginUnwindAssemblyInstEmulation
-lldbPluginDisassemblerLLVM
+lldbPluginDisassemblerLLVMC
 lldbPluginInstructionPPC64
 lldbPluginProcessUtility
   LINK_COMPONENTS
Index: lldb/unittests/UnwindAssembly/ARM64/CMakeLists.txt
===
--- lldb/unittests/UnwindAssembly/ARM64/CMakeLists.txt
+++ lldb/unittests/UnwindAssembly/ARM64/CMakeLists.txt
@@ -5,7 +5,7 @@
 lldbSymbol
 lldbTarget
 lldbPluginUnwindAssemblyInstEmulation
-lldbPluginDisassemblerLLVM
+lldbPluginDisassemblerLLVMC
 lldbPluginInstructionARM64
 lldbPluginProcessUtility
   LINK_COMPONENTS
Index: lldb/unittests/Disassembler/CMakeLists.txt
===
--- lldb/unittests/Disassembler/CMakeLists.txt
+++ lldb/unittests/Disassembler/CMakeLists.txt
@@ -6,7 +6,7 @@
   lldbCore
   lldbSymbol
   lldbTarget
-  lldbPluginDisassemblerLLVM
+  lldbPluginDisassemblerLLVMC
   lldbPluginProcessUtility
 LINK_COMPONENTS
   Support
Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -17,82 +17,8 @@
 
 #include 
 
-LLDB_PLUGIN_DECLARE(ABIAArch64);
-LLDB_PLUGIN_DECLARE(ABIARM);
-LLDB_PLUGIN_DECLARE(ABISysV_arc);
-LLDB_PLUGIN_DECLARE(ABISysV_hexagon);
-LLDB_PLUGIN_DECLARE(ABIMips);
-LLDB_PLUGIN_DECLARE(ABIPowerPC);
-LLDB_PLUGIN_DECLARE(ABISysV_s390x);
-LLDB_PLUGIN_DECLARE(ABIX86);
-LLDB_PLUGIN_DECLARE(ObjectFileBreakpad)
-LLDB_PLUGIN_DECLARE(ObjectFileELF)
-LLDB_PLUGIN_DECLARE(ObjectFileMachO)
-LLDB_PLUGIN_DECLARE(ObjectFilePECOFF)
-LLDB_PLUGIN_DECLARE(ObjectFileWasm)
-LLDB_PLUGIN_DECLARE(ObjectContainerBSDArchive)
-LLDB_PLUGIN_DECLARE(ObjectContainerUniversalMachO)
-LLDB_PLUGIN_DECLARE(ScriptInterpreterNone)
-LLDB_PLUGIN_DECLARE(PlatformFreeBSD)
-LLDB_PLUGIN_DECLARE(PlatformLinux)
-LLDB_PLUGIN_DECLARE(PlatformNetBSD)
-LLDB_PLUGIN_DECLARE(PlatformOpenBSD)
-LLDB_PLUGI

[Lldb-commits] [PATCH] D74743: [lldb] Make header guards consistent across LLDB

2020-02-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcdc514e4c67f: [lldb] Update header guards to be consistent 
and compliant with LLVM (NFC) (authored by JDevlieghere).
Herald added a subscriber: jrtc27.

Changed prior to commit:
  https://reviews.llvm.org/D74743?vs=245045&id=245085#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74743

Files:
  lldb/include/lldb/API/LLDB.h
  lldb/include/lldb/API/SBAddress.h
  lldb/include/lldb/API/SBAttachInfo.h
  lldb/include/lldb/API/SBBlock.h
  lldb/include/lldb/API/SBBreakpoint.h
  lldb/include/lldb/API/SBBreakpointLocation.h
  lldb/include/lldb/API/SBBreakpointName.h
  lldb/include/lldb/API/SBBroadcaster.h
  lldb/include/lldb/API/SBCommandInterpreter.h
  lldb/include/lldb/API/SBCommandReturnObject.h
  lldb/include/lldb/API/SBCommunication.h
  lldb/include/lldb/API/SBCompileUnit.h
  lldb/include/lldb/API/SBData.h
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/API/SBDeclaration.h
  lldb/include/lldb/API/SBDefines.h
  lldb/include/lldb/API/SBError.h
  lldb/include/lldb/API/SBEvent.h
  lldb/include/lldb/API/SBExecutionContext.h
  lldb/include/lldb/API/SBExpressionOptions.h
  lldb/include/lldb/API/SBFile.h
  lldb/include/lldb/API/SBFileSpec.h
  lldb/include/lldb/API/SBFileSpecList.h
  lldb/include/lldb/API/SBFrame.h
  lldb/include/lldb/API/SBFunction.h
  lldb/include/lldb/API/SBHostOS.h
  lldb/include/lldb/API/SBInstruction.h
  lldb/include/lldb/API/SBInstructionList.h
  lldb/include/lldb/API/SBLanguageRuntime.h
  lldb/include/lldb/API/SBLaunchInfo.h
  lldb/include/lldb/API/SBLineEntry.h
  lldb/include/lldb/API/SBListener.h
  lldb/include/lldb/API/SBMemoryRegionInfo.h
  lldb/include/lldb/API/SBMemoryRegionInfoList.h
  lldb/include/lldb/API/SBModule.h
  lldb/include/lldb/API/SBModuleSpec.h
  lldb/include/lldb/API/SBPlatform.h
  lldb/include/lldb/API/SBProcess.h
  lldb/include/lldb/API/SBProcessInfo.h
  lldb/include/lldb/API/SBQueue.h
  lldb/include/lldb/API/SBQueueItem.h
  lldb/include/lldb/API/SBSection.h
  lldb/include/lldb/API/SBSourceManager.h
  lldb/include/lldb/API/SBStream.h
  lldb/include/lldb/API/SBStringList.h
  lldb/include/lldb/API/SBStructuredData.h
  lldb/include/lldb/API/SBSymbol.h
  lldb/include/lldb/API/SBSymbolContext.h
  lldb/include/lldb/API/SBSymbolContextList.h
  lldb/include/lldb/API/SBTarget.h
  lldb/include/lldb/API/SBThread.h
  lldb/include/lldb/API/SBThreadCollection.h
  lldb/include/lldb/API/SBThreadPlan.h
  lldb/include/lldb/API/SBTrace.h
  lldb/include/lldb/API/SBTraceOptions.h
  lldb/include/lldb/API/SBType.h
  lldb/include/lldb/API/SBTypeCategory.h
  lldb/include/lldb/API/SBTypeEnumMember.h
  lldb/include/lldb/API/SBTypeFilter.h
  lldb/include/lldb/API/SBTypeFormat.h
  lldb/include/lldb/API/SBTypeNameSpecifier.h
  lldb/include/lldb/API/SBTypeSummary.h
  lldb/include/lldb/API/SBTypeSynthetic.h
  lldb/include/lldb/API/SBUnixSignals.h
  lldb/include/lldb/API/SBValue.h
  lldb/include/lldb/API/SBValueList.h
  lldb/include/lldb/API/SBVariablesOptions.h
  lldb/include/lldb/API/SBWatchpoint.h
  lldb/include/lldb/Breakpoint/Breakpoint.h
  lldb/include/lldb/Breakpoint/BreakpointID.h
  lldb/include/lldb/Breakpoint/BreakpointIDList.h
  lldb/include/lldb/Breakpoint/BreakpointList.h
  lldb/include/lldb/Breakpoint/BreakpointLocation.h
  lldb/include/lldb/Breakpoint/BreakpointLocationCollection.h
  lldb/include/lldb/Breakpoint/BreakpointLocationList.h
  lldb/include/lldb/Breakpoint/BreakpointName.h
  lldb/include/lldb/Breakpoint/BreakpointOptions.h
  lldb/include/lldb/Breakpoint/BreakpointPrecondition.h
  lldb/include/lldb/Breakpoint/BreakpointResolver.h
  lldb/include/lldb/Breakpoint/BreakpointResolverAddress.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileLine.h
  lldb/include/lldb/Breakpoint/BreakpointResolverFileRegex.h
  lldb/include/lldb/Breakpoint/BreakpointResolverName.h
  lldb/include/lldb/Breakpoint/BreakpointResolverScripted.h
  lldb/include/lldb/Breakpoint/BreakpointSite.h
  lldb/include/lldb/Breakpoint/BreakpointSiteList.h
  lldb/include/lldb/Breakpoint/Stoppoint.h
  lldb/include/lldb/Breakpoint/StoppointCallbackContext.h
  lldb/include/lldb/Breakpoint/StoppointLocation.h
  lldb/include/lldb/Breakpoint/Watchpoint.h
  lldb/include/lldb/Breakpoint/WatchpointList.h
  lldb/include/lldb/Breakpoint/WatchpointOptions.h
  lldb/include/lldb/Core/Address.h
  lldb/include/lldb/Core/AddressRange.h
  lldb/include/lldb/Core/AddressResolver.h
  lldb/include/lldb/Core/AddressResolverFileLine.h
  lldb/include/lldb/Core/AddressResolverName.h
  lldb/include/lldb/Core/Communication.h
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Core/Disassembler.h
  lldb/include/lldb/Core/EmulateInstruction.h
  lldb/include/lldb/Core/FileLineResolver.h
  lldb/include/lldb/Core/FileSpecList.h
  lldb/include/lldb/Core/FormatEntity.h
  lldb/include/lldb/Core/Highlighter.h
  lldb/include/lldb/Core/IOHandler.h
  lldb/include/lldb

[Lldb-commits] [lldb] 8ffea27 - [lldb] Refactor and test TypeSystemClang::GetEnumerationIntegerType

2020-02-18 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-02-18T09:52:49+01:00
New Revision: 8ffea27ae42ad210b9162c3afc91c61dfb82acf7

URL: 
https://github.com/llvm/llvm-project/commit/8ffea27ae42ad210b9162c3afc91c61dfb82acf7
DIFF: 
https://github.com/llvm/llvm-project/commit/8ffea27ae42ad210b9162c3afc91c61dfb82acf7.diff

LOG: [lldb] Refactor and test TypeSystemClang::GetEnumerationIntegerType

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/unittests/Symbol/TestTypeSystemClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 5b3ea8838786..02f481684cd7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -790,8 +790,7 @@ TypeSP DWARFASTParserClang::ParseEnum(const SymbolContext 
&sc,
 attrs.name.GetCString(), GetClangDeclContextContainingDIE(die, 
nullptr),
 attrs.decl, enumerator_clang_type, attrs.is_scoped_enum);
   } else {
-enumerator_clang_type =
-m_ast.GetEnumerationIntegerType(clang_type.GetOpaqueQualType());
+enumerator_clang_type = m_ast.GetEnumerationIntegerType(clang_type);
   }
 
   LinkDeclContextToDIE(TypeSystemClang::GetDeclContextForType(clang_type), 
die);

diff  --git a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp 
b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
index 48bc57272c2a..a03878890d5c 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
@@ -1154,8 +1154,7 @@ bool PDBASTParser::AddEnumValue(CompilerType enum_type,
   default:
 return false;
   }
-  CompilerType underlying_type =
-  m_ast.GetEnumerationIntegerType(enum_type.GetOpaqueQualType());
+  CompilerType underlying_type = m_ast.GetEnumerationIntegerType(enum_type);
   uint32_t byte_size = m_ast.getASTContext().getTypeSize(
   ClangUtil::GetQualType(underlying_type));
   auto enum_constant_decl = m_ast.AddEnumerationValueToEnumerationType(

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 2fa5dc38eb8e..475c927f6114 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -7899,8 +7899,7 @@ clang::EnumConstantDecl 
*TypeSystemClang::AddEnumerationValueToEnumerationType(
 clang::EnumConstantDecl *TypeSystemClang::AddEnumerationValueToEnumerationType(
 const CompilerType &enum_type, const Declaration &decl, const char *name,
 int64_t enum_value, uint32_t enum_value_bit_size) {
-  CompilerType underlying_type =
-  GetEnumerationIntegerType(enum_type.GetOpaqueQualType());
+  CompilerType underlying_type = GetEnumerationIntegerType(enum_type);
   bool is_signed = false;
   underlying_type.IsIntegerType(is_signed);
 
@@ -7910,20 +7909,14 @@ clang::EnumConstantDecl 
*TypeSystemClang::AddEnumerationValueToEnumerationType(
   return AddEnumerationValueToEnumerationType(enum_type, decl, name, value);
 }
 
-CompilerType
-TypeSystemClang::GetEnumerationIntegerType(lldb::opaque_compiler_type_t type) {
-  clang::QualType enum_qual_type(GetCanonicalQualType(type));
-  const clang::Type *clang_type = enum_qual_type.getTypePtr();
-  if (clang_type) {
-const clang::EnumType *enutype =
-llvm::dyn_cast(clang_type);
-if (enutype) {
-  clang::EnumDecl *enum_decl = enutype->getDecl();
-  if (enum_decl)
-return GetType(enum_decl->getIntegerType());
-}
-  }
-  return CompilerType();
+CompilerType TypeSystemClang::GetEnumerationIntegerType(CompilerType type) {
+  clang::QualType qt(ClangUtil::GetQualType(type));
+  const clang::Type *clang_type = qt.getTypePtrOrNull();
+  const auto *enum_type = llvm::dyn_cast_or_null(clang_type);
+  if (!enum_type)
+return CompilerType();
+
+  return GetType(enum_type->getDecl()->getIntegerType());
 }
 
 CompilerType

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index dc9a10bd61a0..2fd12c81c133 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -857,7 +857,10 @@ class TypeSystemClang : public TypeSystem {
   const CompilerType &enum_type, const Declaration &decl, const char *name,
   const llvm::APSInt &value);
 
-  CompilerType GetEnumerationIntegerType(lldb::opaque_compiler_type_t type);
+  /// Returns the underlying integer type for an enum type. If the given type
+  /// is invalid or not an enum-type, the function return

[Lldb-commits] [PATCH] D74727: Allow customized relative PYTHONHOME

2020-02-18 Thread Pavel Labath via Phabricator via lldb-commits
labath added a reviewer: ted.
labath added a comment.

+ ted, who I believe has a stake in the relocatable python game

Your use case seems reasonable, but I find it hard to understand the meanings 
of the options in this patch. IIUC, there are now two ways to create an lldb 
with a "relocatable" python

1. set `LLDB_RELOCATABLE_PYTHON` to `ON`, and set the `PYTHONHOME` environment 
variable before launching lldb
2. set `LLDB_RELOCATABLE_PYTHON` to `OFF`, and also set `LLDB_PYTHON_HOME` to a 
relative path

It took me like five minutes to understand how setting 
`LLDB_RELOCATABLE_PYTHON=OFF` can help you ship python side-by-side with lldb 
(i.e. make it position indepent/relocatable). I think the main cause of the 
confusion is that the name `LLDB_RELOCATABLE_PYTHON` does not express very well 
what that option does -- it really should be something like 
`LLDB_EMBED_PYTHON_HOME`. Can we maybe rename it to something like that? Or 
maybe even just a single LLDB_PYTHON_HOME variable, with the empty value 
meaning we use the default python mechanism (PYTHONHOME env var, or the 
baked-in python default)?

The other thing which bugs me is that the relative python path chosen here will 
likely only be correct once lldb is installed. Will it be possible to run lldb 
(and its test suite) configured in this way directly from the build tree? I 
don't know if there's anything we can or should do about that, but this 
situation seems less than ideal...




Comment at: lldb/cmake/modules/LLDBConfig.cmake:68
+
+option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." {default_relocatable_python})
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install 
a copy of it" OFF)

missing `$` in {default_relocatable_python}



Comment at: lldb/cmake/modules/LLDBConfig.cmake:153
+set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
+  "Path to use as PYTHONHONE in lldb. If a relative path is specified, \
+  it will be resolved at runtime relative to liblldb directory.")

typo PYTHONHONE



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp:298
+llvm::sys::path::append(path, lldb_python_home);
+llvm::sys::path::remove_dots(path, /* remove_dot_dots = */ true);
+absolute_python_home = path.c_str();

Is the `remove_dot_dots` really necessary? It can produce unexpected results 
when `..`s back up over symlinks...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74727



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


[Lldb-commits] [PATCH] D74217: Add target.xml support for qXfer request.

2020-02-18 Thread Levon Ter-Grigoryan via Phabricator via lldb-commits
PatriosTheGreat added a comment.

Hi Muhammad,

Thank you for finding this issue.
After I fix that, could I update current review or should I create new one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74217



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


[Lldb-commits] [lldb] 5783587 - [lldb][NFC] Modernize documentation in lldb-private-types.h

2020-02-18 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-02-18T10:25:27+01:00
New Revision: 57835875bd4346ba00f7f6ded5e1382e26b3fd5c

URL: 
https://github.com/llvm/llvm-project/commit/57835875bd4346ba00f7f6ded5e1382e26b3fd5c
DIFF: 
https://github.com/llvm/llvm-project/commit/57835875bd4346ba00f7f6ded5e1382e26b3fd5c.diff

LOG: [lldb][NFC] Modernize documentation in lldb-private-types.h

Added: 


Modified: 
lldb/include/lldb/lldb-private-types.h

Removed: 




diff  --git a/lldb/include/lldb/lldb-private-types.h 
b/lldb/include/lldb/lldb-private-types.h
index 623936df73b8..2034c6c17909 100644
--- a/lldb/include/lldb/lldb-private-types.h
+++ b/lldb/include/lldb/lldb-private-types.h
@@ -28,38 +28,42 @@ class ExecutionContext;
 typedef llvm::sys::DynamicLibrary (*LoadPluginCallbackType)(
 const lldb::DebuggerSP &debugger_sp, const FileSpec &spec, Status &error);
 
-// Every register is described in detail including its name, alternate name
-// (optional), encoding, size in bytes and the default display format.
+/// Every register is described in detail including its name, alternate name
+/// (optional), encoding, size in bytes and the default display format.
 struct RegisterInfo {
-  const char *name; // Name of this register, can't be NULL
-  const char *alt_name; // Alternate name of this register, can be NULL
-  uint32_t byte_size;   // Size in bytes of the register
-  uint32_t byte_offset; // The byte offset in the register context data where
-// this register's value is found.
-  // This is optional, and can be 0 if a particular RegisterContext does not
-  // need to address its registers by byte offset.
-  lldb::Encoding encoding; // Encoding of the register bits
-  lldb::Format format; // Default display format
-  uint32_t kinds[lldb::kNumRegisterKinds]; // Holds all of the various register
-   // numbers for all register kinds
-  uint32_t *value_regs;// List of registers (terminated 
with
-// LLDB_INVALID_REGNUM).  If this value is not null,
-// all registers in this list will be read first, at
-// which point the value for this register will be
-// valid.  For example, the value list for ah would be
-// eax (x86) or rax (x64).
-  uint32_t *invalidate_regs; // List of registers (terminated with
- // LLDB_INVALID_REGNUM).  If this value is not
- // null, all registers in this list will be
- // invalidated when the value of this register
- // changes.  For example, the invalidate list for
- // eax would be rax ax, ah, and al.
-  const uint8_t *dynamic_size_dwarf_expr_bytes; // A DWARF expression that when
-// evaluated gives
-  // the byte size of this register.
-  size_t dynamic_size_dwarf_len; // The length of the DWARF expression in bytes
- // in the dynamic_size_dwarf_expr_bytes
- // member.
+  /// Name of this register, can't be NULL.
+  const char *name;
+  /// Alternate name of this register, can be NULL.
+  const char *alt_name;
+  /// Size in bytes of the register.
+  uint32_t byte_size;
+  /// The byte offset in the register context data where this register's
+  /// value is found.
+  /// This is optional, and can be 0 if a particular RegisterContext does not
+  /// need to address its registers by byte offset.
+  uint32_t byte_offset;
+  /// Encoding of the register bits.
+  lldb::Encoding encoding;
+  /// Default display format.
+  lldb::Format format;
+  /// Holds all of the various register numbers for all register kinds.
+  uint32_t kinds[lldb::kNumRegisterKinds]; //
+  /// List of registers (terminated with LLDB_INVALID_REGNUM). If this value is
+  /// not null, all registers in this list will be read first, at which point
+  /// the value for this register will be valid. For example, the value list
+  /// for ah would be eax (x86) or rax (x64).
+  uint32_t *value_regs; //
+  /// List of registers (terminated with LLDB_INVALID_REGNUM). If this value is
+  /// not null, all registers in this list will be invalidated when the value 
of
+  /// this register changes. For example, the invalidate list for eax would be
+  /// rax ax, ah, and al.
+  uint32_t *invalidate_regs;
+  /// A DWARF expression that when evaluated gives the byte size of this
+  /// register.
+  const uint8_t *dynamic_size_dwarf_expr_bytes;
+  /// The length of the DWARF expression in bytes in the
+  /// dynamic_size_dwarf_expr_bytes member.
+  size_t dynamic_size_dwarf_len;
 
   llvm::ArrayRef data(const uint8_t *context_base) const {
 return llvm::ArrayRef(c

[Lldb-commits] [lldb] 0ba247b - [lldb] Remove the mutable specifier from DataExtractor's member

2020-02-18 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-02-18T10:26:43+01:00
New Revision: 0ba247bc21f8aed000e649882e6e360fb90e81e5

URL: 
https://github.com/llvm/llvm-project/commit/0ba247bc21f8aed000e649882e6e360fb90e81e5
DIFF: 
https://github.com/llvm/llvm-project/commit/0ba247bc21f8aed000e649882e6e360fb90e81e5.diff

LOG: [lldb] Remove the mutable specifier from DataExtractor's member

Having m_data_sp mutable sounds like a very bad idea. Fortunately,
nothing relies on this possibility.

Added: 


Modified: 
lldb/include/lldb/Utility/DataExtractor.h

Removed: 




diff  --git a/lldb/include/lldb/Utility/DataExtractor.h 
b/lldb/include/lldb/Utility/DataExtractor.h
index 7157b89e86da..7f09b7114a8d 100644
--- a/lldb/include/lldb/Utility/DataExtractor.h
+++ b/lldb/include/lldb/Utility/DataExtractor.h
@@ -1005,8 +1005,8 @@ class DataExtractor {
   m_byte_order; ///< The byte order of the data we are extracting from.
   uint32_t m_addr_size; ///< The address size to use when extracting pointers 
or
 /// addresses
-  mutable lldb::DataBufferSP m_data_sp; ///< The shared pointer to data that 
can
-/// be shared among multiple instances
+  /// The shared pointer to data that can be shared among multiple instances
+  lldb::DataBufferSP m_data_sp;
   const uint32_t m_target_byte_size;
 };
 



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


[Lldb-commits] [PATCH] D74217: Add target.xml support for qXfer request.

2020-02-18 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Please update the current one to keep the context together.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74217



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


[Lldb-commits] [lldb] f14680c - [lldb][NFC] Documention that OptionDefinition::completion_type contains enum values

2020-02-18 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-02-18T10:33:38+01:00
New Revision: f14680ce29663d098593e2f4e0eea96dbcaae0fb

URL: 
https://github.com/llvm/llvm-project/commit/f14680ce29663d098593e2f4e0eea96dbcaae0fb
DIFF: 
https://github.com/llvm/llvm-project/commit/f14680ce29663d098593e2f4e0eea96dbcaae0fb.diff

LOG: [lldb][NFC] Documention that OptionDefinition::completion_type contains 
enum values

This should be just the enum type but that's a larger refactoring, so document 
that
this is not just an integer until we can make this just the type of the enum.

Added: 


Modified: 
lldb/include/lldb/lldb-private-types.h

Removed: 




diff  --git a/lldb/include/lldb/lldb-private-types.h 
b/lldb/include/lldb/lldb-private-types.h
index 2034c6c17909..fb8c2db2e21c 100644
--- a/lldb/include/lldb/lldb-private-types.h
+++ b/lldb/include/lldb/lldb-private-types.h
@@ -124,7 +124,8 @@ struct OptionDefinition {
   OptionValidator *validator;
   /// If not empty, an array of enum values.
   OptionEnumValues enum_values;
-  /// Cookie the option class can use to do define the argument completion.
+  /// The kind of completion for this option.
+  /// Contains values of the CommandCompletions::CommonCompletionTypes enum.
   uint32_t completion_type;
   /// Type of argument this option takes.
   lldb::CommandArgumentType argument_type;



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


[Lldb-commits] [lldb] 0863f67 - [lldb] Remove DataExtractor::GetPointer

2020-02-18 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-02-18T10:38:41+01:00
New Revision: 0863f6757953684400162f2ad418f3e8e28af278

URL: 
https://github.com/llvm/llvm-project/commit/0863f6757953684400162f2ad418f3e8e28af278
DIFF: 
https://github.com/llvm/llvm-project/commit/0863f6757953684400162f2ad418f3e8e28af278.diff

LOG: [lldb] Remove DataExtractor::GetPointer

This function is equivalent to GetAddress, but getAddress is also
present on the llvm version of the data extractor.

Added: 


Modified: 
lldb/include/lldb/Utility/DataExtractor.h
lldb/source/Core/ValueObject.cpp
lldb/source/Core/ValueObjectDynamicValue.cpp
lldb/source/Expression/DWARFExpression.cpp
lldb/source/Expression/Materializer.cpp
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp
lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Symbol/DWARFCallFrameInfo.cpp
lldb/source/Utility/DataExtractor.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/DataExtractor.h 
b/lldb/include/lldb/Utility/DataExtractor.h
index 7f09b7114a8d..8f82ae5af42d 100644
--- a/lldb/include/lldb/Utility/DataExtractor.h
+++ b/lldb/include/lldb/Utility/DataExtractor.h
@@ -573,24 +573,6 @@ class DataExtractor {
 uint32_t bitfield_bit_size,
 uint32_t bitfield_bit_offset) const;
 
-  /// Extract an pointer from \a *offset_ptr.
-  ///
-  /// Extract a single pointer from the data and update the offset pointed to
-  /// by \a offset_ptr. The size of the extracted pointer comes from the \a
-  /// m_addr_size member variable and should be set correctly prior to
-  /// extracting any pointer values.
-  ///
-  /// \param[in,out] offset_ptr
-  /// A pointer to an offset within the data that will be advanced
-  /// by the appropriate number of bytes if the value is extracted
-  /// correctly. If the offset is out of bounds or there are not
-  /// enough bytes to extract this value, the offset will be left
-  /// unmodified.
-  ///
-  /// \return
-  /// The extracted pointer value as a 64 integer.
-  uint64_t GetPointer(lldb::offset_t *offset_ptr) const;
-
   /// Get the current byte order value.
   ///
   /// \return
@@ -1003,8 +985,7 @@ class DataExtractor {
   *m_end; ///< A pointer to the byte that is past the end of the data.
   lldb::ByteOrder
   m_byte_order; ///< The byte order of the data we are extracting from.
-  uint32_t m_addr_size; ///< The address size to use when extracting pointers 
or
-/// addresses
+  uint32_t m_addr_size; ///< The address size to use when extracting addresses.
   /// The shared pointer to data that can be shared among multiple instances
   lldb::DataBufferSP m_data_sp;
   const uint32_t m_target_byte_size;

diff  --git a/lldb/source/Core/ValueObject.cpp 
b/lldb/source/Core/ValueObject.cpp
index 71ceef7798d3..e1d0ca941108 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -1551,7 +1551,7 @@ addr_t ValueObject::GetPointerValue(AddressType 
*address_type) {
   case Value::eValueTypeLoadAddress:
   case Value::eValueTypeFileAddress: {
 lldb::offset_t data_offset = 0;
-address = m_data.GetPointer(&data_offset);
+address = m_data.GetAddress(&data_offset);
   } break;
   }
 

diff  --git a/lldb/source/Core/ValueObjectDynamicValue.cpp 
b/lldb/source/Core/ValueObjectDynamicValue.cpp
index 149984df1841..ca66740cb55d 100644
--- a/lldb/source/Core/ValueObjectDynamicValue.cpp
+++ b/lldb/source/Core/ValueObjectDynamicValue.cpp
@@ -327,7 +327,7 @@ bool ValueObjectDynamicValue::SetData(DataExtractor &data, 
Status &error) {
 // but NULL'ing out a value should always be allowed
 lldb::offset_t offset = 0;
 
-if (data.GetPointer(&offset) != 0) {
+if (data.GetAddress(&offset) != 0) {
   error.SetErrorString(
   "unable to modify dynamic value, use 'expression' command");
   return false;

diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 849c96d9b455..7f12d06450c6 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -1182,7 +1182,7 @@ bool DWARFExpression::Evaluate(
 break;
   default:

[Lldb-commits] [lldb] 7d13812 - [lldb] Fix compilation of SymbolFilePDBTests.cpp after FindTypes API change

2020-02-18 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-02-18T10:52:02+01:00
New Revision: 7d13812329ba8aadebc27f30613e79b0ca1bec5f

URL: 
https://github.com/llvm/llvm-project/commit/7d13812329ba8aadebc27f30613e79b0ca1bec5f
DIFF: 
https://github.com/llvm/llvm-project/commit/7d13812329ba8aadebc27f30613e79b0ca1bec5f.diff

LOG: [lldb] Fix compilation of SymbolFilePDBTests.cpp after FindTypes API change

Since f9568a95493aea3ea813bd37cb8c084ec4294e38 this function takes a
CompilerDeclContext reference instead of a pointer.

Added: 


Modified: 
lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Removed: 




diff  --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp 
b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
index 880daaee056b..44f77ef0044f 100644
--- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -355,7 +355,8 @@ TEST_F(SymbolFilePDBTests, TestSimpleClassTypes) {
   llvm::pdb::IPDBSession &session = symfile->GetPDBSession();
   llvm::DenseSet searched_files;
   TypeMap results;
-  symfile->FindTypes(ConstString("Class"), nullptr, 0, searched_files, 
results);
+  symfile->FindTypes(ConstString("Class"), CompilerDeclContext(), 0,
+ searched_files, results);
   EXPECT_EQ(1u, results.GetSize());
   lldb::TypeSP udt_type = results.GetTypeAtIndex(0);
   EXPECT_EQ(ConstString("Class"), udt_type->GetName());
@@ -384,7 +385,8 @@ TEST_F(SymbolFilePDBTests, TestNestedClassTypes) {
   llvm::dyn_cast_or_null(&clang_ast_ctx_or_err.get());
   EXPECT_NE(nullptr, clang_ast_ctx);
 
-  symfile->FindTypes(ConstString("Class"), nullptr, 0, searched_files, 
results);
+  symfile->FindTypes(ConstString("Class"), CompilerDeclContext(), 0,
+ searched_files, results);
   EXPECT_EQ(1u, results.GetSize());
 
   auto Class = results.GetTypeAtIndex(0);
@@ -404,7 +406,7 @@ TEST_F(SymbolFilePDBTests, TestNestedClassTypes) {
 
   TypeMap more_results;
   auto ClassCompilerDeclCtx = CompilerDeclContext(clang_ast_ctx, ClassDeclCtx);
-  symfile->FindTypes(ConstString("NestedClass"), &ClassCompilerDeclCtx, 0,
+  symfile->FindTypes(ConstString("NestedClass"), ClassCompilerDeclCtx, 0,
  searched_files, more_results);
   EXPECT_LE(1u, more_results.GetSize());
 
@@ -448,7 +450,7 @@ TEST_F(SymbolFilePDBTests, TestClassInNamespace) {
   auto ns_namespace = symfile->FindNamespace(ConstString("NS"), nullptr);
   EXPECT_TRUE(ns_namespace.IsValid());
 
-  symfile->FindTypes(ConstString("NSClass"), &ns_namespace, 0, searched_files,
+  symfile->FindTypes(ConstString("NSClass"), ns_namespace, 0, searched_files,
  results);
   EXPECT_EQ(1u, results.GetSize());
 
@@ -474,7 +476,8 @@ TEST_F(SymbolFilePDBTests, TestEnumTypes) {
   const char *EnumsToCheck[] = {"Enum", "ShortEnum"};
   for (auto Enum : EnumsToCheck) {
 TypeMap results;
-symfile->FindTypes(ConstString(Enum), nullptr, 0, searched_files, results);
+symfile->FindTypes(ConstString(Enum), CompilerDeclContext(), 0,
+   searched_files, results);
 EXPECT_EQ(1u, results.GetSize());
 lldb::TypeSP enum_type = results.GetTypeAtIndex(0);
 EXPECT_EQ(ConstString(Enum), enum_type->GetName());
@@ -522,8 +525,8 @@ TEST_F(SymbolFilePDBTests, TestTypedefs) {
"VariadicFuncPointerTypedef"};
   for (auto Typedef : TypedefsToCheck) {
 TypeMap results;
-symfile->FindTypes(ConstString(Typedef), nullptr, 0, searched_files,
-   results);
+symfile->FindTypes(ConstString(Typedef), CompilerDeclContext(), 0,
+   searched_files, results);
 EXPECT_EQ(1u, results.GetSize());
 lldb::TypeSP typedef_type = results.GetTypeAtIndex(0);
 EXPECT_EQ(ConstString(Typedef), typedef_type->GetName());
@@ -568,7 +571,7 @@ TEST_F(SymbolFilePDBTests, TestMaxMatches) {
   llvm::DenseSet searched_files;
   TypeMap results;
   const ConstString name("ClassTypedef");
-  symfile->FindTypes(name, nullptr, 0, searched_files, results);
+  symfile->FindTypes(name, CompilerDeclContext(), 0, searched_files, results);
   // Try to limit ourselves from 1 to 10 results, otherwise we could
   // be doing this thousands of times.  The idea is just to make sure
   // that for a variety of values, the number of limited results
@@ -577,7 +580,8 @@ TEST_F(SymbolFilePDBTests, TestMaxMatches) {
   uint32_t iterations = std::min(num_results, 10u);
   for (uint32_t i = 1; i <= iterations; ++i) {
 TypeMap more_results;
-symfile->FindTypes(name, nullptr, i, searched_files, more_results);
+symfile->FindTypes(name, CompilerDeclContext(), i, searched_files,
+   more_results);
 uint32_t num_limited_results = more_results.GetSize();
 EXPECT_EQ(i, num_limited_results);
   }
@@ -592,7 +596,8 @@ TEST_F(SymbolFilePDBTests, TestNullName) {
   static_cast(

[Lldb-commits] [lldb] 00539d8 - [lldb/DWARF] Support the debug_str_offsets section in dwp files

2020-02-18 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-02-18T11:02:34+01:00
New Revision: 00539d8b6425529240d970082c23e6ee1263669b

URL: 
https://github.com/llvm/llvm-project/commit/00539d8b6425529240d970082c23e6ee1263669b
DIFF: 
https://github.com/llvm/llvm-project/commit/00539d8b6425529240d970082c23e6ee1263669b.diff

LOG: [lldb/DWARF] Support the debug_str_offsets section in dwp files

Summary:
In dwp files a constant (from the debug_cu_index section) needs to be
added to each reference into the debug_str_offsets section.

I've tried to implement this to roughly match the llvm flow: I've
changed the DWARFormValue to stop resolving the indirect string
references directly -- instead, it calls into DWARFUnit, which resolves
this for it (similar to how it already resolves indirect range and
location list references). I've also done a small refactor of the string
offset base computation code in DWARFUnit in order to make it easier to
access the debug_cu_index base offset.

Reviewers: JDevlieghere, aprantl, clayborg

Subscribers: lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74723

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/test/Shell/SymbolFile/DWARF/dwp.s

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
index d1a27981f025..83cda24a27d2 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
@@ -454,40 +454,26 @@ void DWARFFormValue::Dump(Stream &s) const {
 }
 
 const char *DWARFFormValue::AsCString() const {
-  SymbolFileDWARF &symbol_file = m_unit->GetSymbolFileDWARF();
+  DWARFContext &context = m_unit->GetSymbolFileDWARF().GetDWARFContext();
 
-  if (m_form == DW_FORM_string) {
+  if (m_form == DW_FORM_string)
 return m_value.value.cstr;
-  } else if (m_form == DW_FORM_strp) {
-return symbol_file.GetDWARFContext().getOrLoadStrData().PeekCStr(
-m_value.value.uval);
-  } else if (m_form == DW_FORM_GNU_str_index) {
-uint32_t index_size = 4;
-lldb::offset_t offset = m_value.value.uval * index_size;
-dw_offset_t str_offset =
-symbol_file.GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64(
-&offset, index_size);
-return symbol_file.GetDWARFContext().getOrLoadStrData().PeekCStr(
-str_offset);
-  }
-
-  if (m_form == DW_FORM_strx || m_form == DW_FORM_strx1 ||
-  m_form == DW_FORM_strx2 || m_form == DW_FORM_strx3 ||
-  m_form == DW_FORM_strx4) {
-
-// The same code as above.
-uint32_t indexSize = 4;
-lldb::offset_t offset =
-m_unit->GetStrOffsetsBase() + m_value.value.uval * indexSize;
-dw_offset_t strOffset =
-symbol_file.GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64(
-&offset, indexSize);
-return 
symbol_file.GetDWARFContext().getOrLoadStrData().PeekCStr(strOffset);
+  if (m_form == DW_FORM_strp)
+return context.getOrLoadStrData().PeekCStr(m_value.value.uval);
+
+  if (m_form == DW_FORM_GNU_str_index || m_form == DW_FORM_strx ||
+  m_form == DW_FORM_strx1 || m_form == DW_FORM_strx2 ||
+  m_form == DW_FORM_strx3 || m_form == DW_FORM_strx4) {
+
+llvm::Optional offset =
+m_unit->GetStringOffsetSectionItem(m_value.value.uval);
+if (!offset)
+  return nullptr;
+return context.getOrLoadStrData().PeekCStr(*offset);
   }
 
   if (m_form == DW_FORM_line_strp)
-return symbol_file.GetDWARFContext().getOrLoadLineStrData().PeekCStr(
-m_value.value.uval);
+return context.getOrLoadLineStrData().PeekCStr(m_value.value.uval);
 
   return nullptr;
 }

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 37e52331faca..6ff3601ab049 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -259,23 +259,32 @@ void DWARFUnit::ExtractDIEsRWLocked() {
 // .debug_str_offsets. At the same time, the corresponding split debug unit 
also
 // may use DW_FORM_strx* forms pointing to its own .debug_str_offsets.dwo and
 // for that case, we should find the offset (skip the section header).
-static void SetDwoStrOffsetsBase(DWARFUnit *dwo_cu) {
+void DWARFUnit::SetDwoStrOffsetsBase() {
   lldb::offset_t baseOffset = 0;
 
-  const DWARFDataExtractor &strOffsets =
-  dwo_cu->GetSymbolFileDWARF().GetDWARFContext().getOrLoadStrOffsetsData();
-  uint64_t length = strOffsets.GetU32(&baseOffset);
-  if (length == 0x)
-length = strOffsets.GetU64(&baseOffset);
+  if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
+if (const auto *contribution = entry->getOffset(llvm::DW_SECT_STR_OFFSETS)

[Lldb-commits] [PATCH] D74723: [lldb/DWARF] Support the debug_str_offsets section in dwp files

2020-02-18 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG00539d8b6425: [lldb/DWARF] Support the debug_str_offsets 
section in dwp files (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74723

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/test/Shell/SymbolFile/DWARF/dwp.s

Index: lldb/test/Shell/SymbolFile/DWARF/dwp.s
===
--- lldb/test/Shell/SymbolFile/DWARF/dwp.s
+++ lldb/test/Shell/SymbolFile/DWARF/dwp.s
@@ -5,10 +5,10 @@
 # RUN: %lldb %t -o "target variable A" -b | FileCheck %s
 # RUN: lldb-test symbols %t | FileCheck %s --check-prefix=SYMBOLS
 
-# CHECK: (int) A = 0
-# CHECK: (int) A = 1
-# CHECK: (int) A = 2
-# CHECK: (int) A = 3
+# CHECK: (INT0) A = 0
+# CHECK: (INT1) A = 1
+# CHECK: (INT2) A = 2
+# CHECK: (INT3) A = 3
 
 # SYMBOLS:  Compile units:
 # SYMBOLS-NEXT: CompileUnit{0x}, language = "unknown", file = '0.c'
@@ -64,6 +64,15 @@
 # This deliberately excludes compile unit 4 to check test the case of a missing
 # split unit.
 .irpc I,0123
+.section.debug_str.dwo,"e",@progbits
+.Lstr\I:
+.byte   'I', 'N', 'T', '0'+\I, 0
+
+.section.debug_str_offsets.dwo,"e",@progbits
+.Lstr_offsets\I:
+.long   .Lstr\I-.debug_str.dwo
+.Lstr_offsets_end\I:
+
 .section.debug_abbrev.dwo,"e",@progbits
 .Labbrev\I:
 .byte   \I*10+1 # Abbreviation Code
@@ -90,13 +99,22 @@
 .byte   36  # DW_TAG_base_type
 .byte   0   # DW_CHILDREN_no
 .byte   3   # DW_AT_name
-.byte   14  # DW_FORM_string
+.byte   8   # DW_FORM_string
 .byte   62  # DW_AT_encoding
 .byte   11  # DW_FORM_data1
 .byte   11  # DW_AT_byte_size
 .byte   11  # DW_FORM_data1
 .byte   0   # EOM(1)
 .byte   0   # EOM(2)
+.byte   \I*10+4 # Abbreviation Code
+.byte   22  # DW_TAG_typedef
+.byte   0   # DW_CHILDREN_no
+.byte   3   # DW_AT_name
+.uleb128 0x1f02 # DW_FORM_GNU_str_index
+.byte   73  # DW_AT_type
+.byte   19  # DW_FORM_ref4
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
 .byte   0   # EOM(3)
 .Labbrev_end\I:
 
@@ -112,10 +130,14 @@
 .byte   '0'+\I, '.', 'c', 0 # DW_AT_name
 .byte   \I*10+2 # Abbrev DW_TAG_variable
 .asciz  "A" # DW_AT_name
-.long   .Ltype\I-.Lcu_begin\I   # DW_AT_type
+.long   .Ltypedef\I-.Lcu_begin\I# DW_AT_type
 .byte   2   # DW_AT_location
 .byte   0xfb# DW_OP_GNU_addr_index
 .byte   \I
+.Ltypedef\I:
+.byte   \I*10+4 # Abbrev DW_TAG_typedef
+.byte   0   # DW_AT_name
+.long   .Ltype\I-.Lcu_begin\I   # DW_AT_type
 .Ltype\I:
 .byte   \I*10+3 # Abbrev DW_TAG_base_type
 .asciz  "int"   # DW_AT_name
@@ -128,22 +150,26 @@
 .section.debug_cu_index,"e",@progbits
 .short  2   # DWARF version number
 .short  0   # Reserved
-.long   2   # Section count
+.long   3   # Section count
 .long   4   # Unit count
 .long   8   # Slot count
 
 .quad   0, 1, 2, 3, 0, 0, 0, 0  # Hash table
 .long   1, 2, 3, 4, 0, 0, 0, 0  # Index table
 
-.long   1, 3# DW_SECT_INFO, DW_SECT_ABBREV
+.long   1   # DW_SECT_INFO
+.long   3   # DW_SECT_ABBREV
+.long   6   # DW_SECT_STR_OFFSETS
 
 .irpc I,0123
 .long .Lcu_begin\I-.debug_info.dwo
 .long .Labbrev\I-.debug_abbrev.dwo
+.long .Lstr_offsets\I-.debug_str_offsets.dwo
 .endr
 .irpc I,0123
 .long .Ldebug_info_end\I-.Lcu_begin\I
 .long .Labbrev_end\I-.Labbrev\I
+.long .Lstr_offsets_end\I-.Lstr_offsets\I
 .endr
 
 .endif
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWAR

[Lldb-commits] [PATCH] D74690: Separate DIERef vs. user_id_t: GetForwardDeclClangTypeToDie()

2020-02-18 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

In D74690#1879121 , @jankratochvil 
wrote:

> Sorry for that `DenseMap::insert`, I see it is the same as `std::map`, I 
> should study `DenseMap` more.


Yep, it tried to be similar to std::map, but there are some (sometimes subtle) 
differences.




Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp:1724
   clang_type.GetOpaqueQualType();
-  dwarf->GetForwardDeclClangTypeToDie()
-  [ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType()] =
-  die.GetID();
+  dwarf->GetForwardDeclClangTypeToDie().insert(std::make_pair(
+  ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType(),

Actually, `try_emplace` would be slightly better here. (Sorry for the 
back-and-forth :/).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74690



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


[Lldb-commits] [lldb] 51d8c59 - [lldb] Don't model std::atomic as a transparent data structure in the data formatter

2020-02-18 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-02-18T11:22:12+01:00
New Revision: 51d8c598331b25568b38691575c39729ae81a059

URL: 
https://github.com/llvm/llvm-project/commit/51d8c598331b25568b38691575c39729ae81a059
DIFF: 
https://github.com/llvm/llvm-project/commit/51d8c598331b25568b38691575c39729ae81a059.diff

LOG: [lldb] Don't model std::atomic as a transparent data structure in the data 
formatter

Summary:
Currently the data formatter is treating `std::atomic` variables as transparent 
wrappers
around their underlying value type. This causes that when printing 
`std::atomic`, the data
formatter will forward all requests for the children of the atomic variable to 
the `A *` pointer type
which will then return the respective members of `A`. If `A` in turn has a 
member that contains
the original atomic variable, this causes LLDB to infinitely recurse when 
printing an object with
such a `std::atomic` pointer member.

We could implement a workaround similar to whatever we do for pointer values 
but this patch
just implements the `std::atomic` formatter in the same way as we already 
implement other
formatters (e.g. smart pointers or `std::optional`) that just model the 
contents of the  as a child
"Value". This way LLDB knows when it actually prints a pointer and can just use 
its normal
workaround if "Value" is a recursive pointer.

Fixes rdar://59189235

Reviewers: JDevlieghere, jingham, shafik

Reviewed By: shafik

Subscribers: shafik, christof, jfb, abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D74310

Added: 


Modified: 
lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
index b045c95c076a..45d4322e93d7 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "LibCxxAtomic.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -100,8 +101,6 @@ class LibcxxStdAtomicSyntheticFrontEnd : public 
SyntheticChildrenFrontEnd {
 
   size_t GetIndexOfChildWithName(ConstString name) override;
 
-  lldb::ValueObjectSP GetSyntheticValue() override;
-
 private:
   ValueObject *m_real_child;
 };
@@ -127,26 +126,20 @@ bool 
lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
 
 size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
 CalculateNumChildren() {
-  return m_real_child ? m_real_child->GetNumChildren() : 0;
+  return m_real_child ? 1 : 0;
 }
 
 lldb::ValueObjectSP
 lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::GetChildAtIndex(
 size_t idx) {
-  return m_real_child ? m_real_child->GetChildAtIndex(idx, true) : nullptr;
+  if (idx == 0)
+return m_real_child->GetSP()->Clone(ConstString("Value"));
+  return nullptr;
 }
 
 size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
 GetIndexOfChildWithName(ConstString name) {
-  return m_real_child ? m_real_child->GetIndexOfChildWithName(name)
-  : UINT32_MAX;
-}
-
-lldb::ValueObjectSP 
lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
-GetSyntheticValue() {
-  if (m_real_child && m_real_child->CanProvideValue())
-return m_real_child->GetSP();
-  return nullptr;
+  return formatters::ExtractIndexFromString(name.GetCString());
 }
 
 SyntheticChildrenFrontEnd *

diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
index 48e77c1a885d..908a2d0e3722 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
@@ -42,13 +42,19 @@ def test(self):
 substrs=['stopped',
  'stop reason = breakpoint'])
 
-s = self.get_variable('s')
-i = self.get_variable('i')
+s_atomic = self.get_variable('s')
+i_atomic = self.get_variable('i')
 
 if self.TraceOn():
-print(s)
+print(s_atomic)
 if self.TraceOn():
-print(i)
+print(i_atomic)
+
+# Extract the content of the std::atomic wrappers.
+self.assertEqual(s_atomic.GetNumChildren(), 1)
+s = s_atomic.GetChildAtIndex(0)
+self.assertEqual(i_atomic.GetNumChildren(), 1

[Lldb-commits] [PATCH] D74310: [lldb] Don't model std::atomic as a transparent data structure in the data formatter

2020-02-18 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor updated this revision to Diff 245109.
teemperor added a comment.

- Expand tests as suggested by Shafik (thanks!)


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

https://reviews.llvm.org/D74310

Files:
  lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp
@@ -8,6 +8,18 @@
 
 #include 
 
+// Define a Parent and Child struct that can point to each other.
+class Parent;
+struct Child {
+  // This should point to the parent which in turn owns this
+  // child instance. This cycle should not cause LLDB to infinite loop
+  // during printing.
+  std::atomic parent{nullptr};
+};
+struct Parent {
+  Child child;
+};
+
 struct S {
 int x = 1;
 int y = 2;
@@ -19,7 +31,11 @@
 s.store(S());
 std::atomic i;
 i.store(5);
-
+
+Parent p;
+// Let the child node know what its parent is.
+p.child.parent = &p;
+
 return 0; // Set break point at this line.
 }
 
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
@@ -42,13 +42,19 @@
 substrs=['stopped',
  'stop reason = breakpoint'])
 
-s = self.get_variable('s')
-i = self.get_variable('i')
+s_atomic = self.get_variable('s')
+i_atomic = self.get_variable('i')
 
 if self.TraceOn():
-print(s)
+print(s_atomic)
 if self.TraceOn():
-print(i)
+print(i_atomic)
+
+# Extract the content of the std::atomic wrappers.
+self.assertEqual(s_atomic.GetNumChildren(), 1)
+s = s_atomic.GetChildAtIndex(0)
+self.assertEqual(i_atomic.GetNumChildren(), 1)
+i = i_atomic.GetChildAtIndex(0)
 
 self.assertTrue(i.GetValueAsUnsigned(0) == 5, "i == 5")
 self.assertTrue(s.GetNumChildren() == 2, "s has two children")
@@ -58,3 +64,9 @@
 self.assertTrue(
 s.GetChildAtIndex(1).GetValueAsUnsigned(0) == 2,
 "s.y == 2")
+
+# Try printing the child that points to its own parent object.
+# This should just treat the atomic pointer as a normal pointer.
+self.expect("frame var p.child", substrs=["Value = 0x"])
+self.expect("frame var p", substrs=["parent = {", "Value = 0x", "}"])
+self.expect("frame var p.child.parent", substrs=["p.child.parent = {\n  Value = 0x"])
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "LibCxxAtomic.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -100,8 +101,6 @@
 
   size_t GetIndexOfChildWithName(ConstString name) override;
 
-  lldb::ValueObjectSP GetSyntheticValue() override;
-
 private:
   ValueObject *m_real_child;
 };
@@ -127,26 +126,20 @@
 
 size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
 CalculateNumChildren() {
-  return m_real_child ? m_real_child->GetNumChildren() : 0;
+  return m_real_child ? 1 : 0;
 }
 
 lldb::ValueObjectSP
 lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::GetChildAtIndex(
 size_t idx) {
-  return m_real_child ? m_real_child->GetChildAtIndex(idx, true) : nullptr;
+  if (idx == 0)
+return m_real_child->GetSP()->Clone(ConstString("Value"));
+  return nullptr;
 }
 
 size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
 GetIndexOfChildWithName(ConstString name) {
-  return m_real_child ? m_real_child->GetIndexOfChildWithName(name)
-  : UINT32_MAX;
-}
-
-lldb::ValueObjectSP lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
-GetSyntheticValue() {
-  if (m_real_child && m_real_child->CanProvideValue())
-return m_real_child->GetSP();
-  return nullptr;
+  return formatters::ExtractIndexFromString(name.GetCString());
 }
 
 SyntheticChildrenFrontEnd *
___
lldb-commits maili

[Lldb-commits] [PATCH] D74310: [lldb] Don't model std::atomic as a transparent data structure in the data formatter

2020-02-18 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG51d8c598331b: [lldb] Don't model std::atomic as a 
transparent data structure in the data… (authored by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74310

Files:
  lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/main.cpp
@@ -8,6 +8,18 @@
 
 #include 
 
+// Define a Parent and Child struct that can point to each other.
+class Parent;
+struct Child {
+  // This should point to the parent which in turn owns this
+  // child instance. This cycle should not cause LLDB to infinite loop
+  // during printing.
+  std::atomic parent{nullptr};
+};
+struct Parent {
+  Child child;
+};
+
 struct S {
 int x = 1;
 int y = 2;
@@ -19,7 +31,11 @@
 s.store(S());
 std::atomic i;
 i.store(5);
-
+
+Parent p;
+// Let the child node know what its parent is.
+p.child.parent = &p;
+
 return 0; // Set break point at this line.
 }
 
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/atomic/TestLibCxxAtomic.py
@@ -42,13 +42,19 @@
 substrs=['stopped',
  'stop reason = breakpoint'])
 
-s = self.get_variable('s')
-i = self.get_variable('i')
+s_atomic = self.get_variable('s')
+i_atomic = self.get_variable('i')
 
 if self.TraceOn():
-print(s)
+print(s_atomic)
 if self.TraceOn():
-print(i)
+print(i_atomic)
+
+# Extract the content of the std::atomic wrappers.
+self.assertEqual(s_atomic.GetNumChildren(), 1)
+s = s_atomic.GetChildAtIndex(0)
+self.assertEqual(i_atomic.GetNumChildren(), 1)
+i = i_atomic.GetChildAtIndex(0)
 
 self.assertTrue(i.GetValueAsUnsigned(0) == 5, "i == 5")
 self.assertTrue(s.GetNumChildren() == 2, "s has two children")
@@ -58,3 +64,9 @@
 self.assertTrue(
 s.GetChildAtIndex(1).GetValueAsUnsigned(0) == 2,
 "s.y == 2")
+
+# Try printing the child that points to its own parent object.
+# This should just treat the atomic pointer as a normal pointer.
+self.expect("frame var p.child", substrs=["Value = 0x"])
+self.expect("frame var p", substrs=["parent = {", "Value = 0x", "}"])
+self.expect("frame var p.child.parent", substrs=["p.child.parent = {\n  Value = 0x"])
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxAtomic.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "LibCxxAtomic.h"
+#include "lldb/DataFormatters/FormattersHelpers.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -100,8 +101,6 @@
 
   size_t GetIndexOfChildWithName(ConstString name) override;
 
-  lldb::ValueObjectSP GetSyntheticValue() override;
-
 private:
   ValueObject *m_real_child;
 };
@@ -127,26 +126,20 @@
 
 size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
 CalculateNumChildren() {
-  return m_real_child ? m_real_child->GetNumChildren() : 0;
+  return m_real_child ? 1 : 0;
 }
 
 lldb::ValueObjectSP
 lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::GetChildAtIndex(
 size_t idx) {
-  return m_real_child ? m_real_child->GetChildAtIndex(idx, true) : nullptr;
+  if (idx == 0)
+return m_real_child->GetSP()->Clone(ConstString("Value"));
+  return nullptr;
 }
 
 size_t lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
 GetIndexOfChildWithName(ConstString name) {
-  return m_real_child ? m_real_child->GetIndexOfChildWithName(name)
-  : UINT32_MAX;
-}
-
-lldb::ValueObjectSP lldb_private::formatters::LibcxxStdAtomicSyntheticFrontEnd::
-GetSyntheticValue() {
-  if (m_real_child && m_real_child->CanProvideValue())
-return m_real_child->GetSP();
-  return nullptr;
+  return formatters::ExtractIndexFromStri

[Lldb-commits] [lldb] 3f0661b - [lldb][NFC] Fix compilation of SymbolFilePDBTests.cpp after FindNamespace API change

2020-02-18 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-02-18T11:25:12+01:00
New Revision: 3f0661b5e7176e7447ae11ef47195dfe31ab1029

URL: 
https://github.com/llvm/llvm-project/commit/3f0661b5e7176e7447ae11ef47195dfe31ab1029
DIFF: 
https://github.com/llvm/llvm-project/commit/3f0661b5e7176e7447ae11ef47195dfe31ab1029.diff

LOG: [lldb][NFC] Fix compilation of SymbolFilePDBTests.cpp after FindNamespace 
API change

Since f9568a95493aea3ea813bd37cb8c084ec4294e38 this function takes a
CompilerDeclContext reference instead of a pointer. It overlooked this function
when I fixed the compilation for FindTypes.

Added: 


Modified: 
lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Removed: 




diff  --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp 
b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
index 44f77ef0044f..072fe6aaf0f9 100644
--- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -447,7 +447,7 @@ TEST_F(SymbolFilePDBTests, TestClassInNamespace) {
   symfile->ParseDeclsForContext(CompilerDeclContext(
   clang_ast_ctx, static_cast(tu)));
 
-  auto ns_namespace = symfile->FindNamespace(ConstString("NS"), nullptr);
+  auto ns_namespace = symfile->FindNamespace(ConstString("NS"), 
CompilerDeclContext());
   EXPECT_TRUE(ns_namespace.IsValid());
 
   symfile->FindTypes(ConstString("NSClass"), ns_namespace, 0, searched_files,



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


[Lldb-commits] [lldb] 185ef69 - [lldb] Don't call CopyForBreakpoint from a Breakpoint's constructor

2020-02-18 Thread Tatyana Krasnukha via lldb-commits

Author: Tatyana Krasnukha
Date: 2020-02-18T13:49:07+03:00
New Revision: 185ef697ef5c60d7a5c801925e6abdad52226c2b

URL: 
https://github.com/llvm/llvm-project/commit/185ef697ef5c60d7a5c801925e6abdad52226c2b
DIFF: 
https://github.com/llvm/llvm-project/commit/185ef697ef5c60d7a5c801925e6abdad52226c2b.diff

LOG: [lldb] Don't call CopyForBreakpoint from a Breakpoint's constructor

Some implementations (BreakpointResolverScripted) try calling the breakpoint's 
shared_from_this(),
that makes LLDB crash.

Added: 


Modified: 
lldb/include/lldb/Breakpoint/Breakpoint.h
lldb/source/Breakpoint/Breakpoint.cpp
lldb/source/Target/Target.cpp

lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py

Removed: 




diff  --git a/lldb/include/lldb/Breakpoint/Breakpoint.h 
b/lldb/include/lldb/Breakpoint/Breakpoint.h
index 553b911da0f7..c48a0ad73d4e 100644
--- a/lldb/include/lldb/Breakpoint/Breakpoint.h
+++ b/lldb/include/lldb/Breakpoint/Breakpoint.h
@@ -568,6 +568,11 @@ class Breakpoint : public 
std::enable_shared_from_this,
 return GetPermissions().GetAllowDelete();
   }
 
+  // This one should only be used by Target to copy breakpoints from target to
+  // target - primarily from the dummy target to prime new targets.
+  static lldb::BreakpointSP CopyFromBreakpoint(Target& new_target,
+  const Breakpoint &bp_to_copy_from);
+
 protected:
   friend class Target;
   // Protected Methods
@@ -625,9 +630,8 @@ class Breakpoint : public 
std::enable_shared_from_this,
   }
 
 private:
-  // This one should only be used by Target to copy breakpoints from target to
-  // target - primarily from the dummy target to prime new targets.
-  Breakpoint(Target &new_target, Breakpoint &bp_to_copy_from);
+  // To call from CopyFromBreakpoint.
+  Breakpoint(Target &new_target, const Breakpoint &bp_to_copy_from);
 
   // For Breakpoint only
   bool m_being_created;

diff  --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index 78aef01d35aa..39c6828d3f09 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -55,21 +55,26 @@ Breakpoint::Breakpoint(Target &target, SearchFilterSP 
&filter_sp,
   m_being_created = false;
 }
 
-Breakpoint::Breakpoint(Target &new_target, Breakpoint &source_bp)
+Breakpoint::Breakpoint(Target &new_target, const Breakpoint &source_bp)
 : m_being_created(true), m_hardware(source_bp.m_hardware),
   m_target(new_target), m_name_list(source_bp.m_name_list),
   m_options_up(new BreakpointOptions(*source_bp.m_options_up)),
   m_locations(*this),
   m_resolve_indirect_symbols(source_bp.m_resolve_indirect_symbols),
-  m_hit_count(0) {
-  // Now go through and copy the filter & resolver:
-  m_resolver_sp = source_bp.m_resolver_sp->CopyForBreakpoint(*this);
-  m_filter_sp = source_bp.m_filter_sp->CopyForBreakpoint(*this);
-}
+  m_hit_count(0) {}
 
 // Destructor
 Breakpoint::~Breakpoint() = default;
 
+BreakpointSP Breakpoint::CopyFromBreakpoint(Target& new_target,
+const Breakpoint& bp_to_copy_from) {
+  BreakpointSP bp(new Breakpoint(new_target, bp_to_copy_from));
+  // Now go through and copy the filter & resolver:
+  bp->m_resolver_sp = bp_to_copy_from.m_resolver_sp->CopyForBreakpoint(*bp);
+  bp->m_filter_sp = bp_to_copy_from.m_filter_sp->CopyForBreakpoint(*bp);
+  return bp;
+}
+
 // Serialization
 StructuredData::ObjectSP Breakpoint::SerializeToStructuredData() {
   // Serialize the resolver:

diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 9e41e90b6d7d..49cb52bb0498 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -127,12 +127,12 @@ void Target::PrimeFromDummyTarget(Target *target) {
 
   m_stop_hooks = target->m_stop_hooks;
 
-  for (BreakpointSP breakpoint_sp : target->m_breakpoint_list.Breakpoints()) {
+  for (const auto &breakpoint_sp : target->m_breakpoint_list.Breakpoints()) {
 if (breakpoint_sp->IsInternal())
   continue;
 
-BreakpointSP new_bp(new Breakpoint(*this, *breakpoint_sp.get()));
-AddBreakpoint(new_bp, false);
+BreakpointSP new_bp(Breakpoint::CopyFromBreakpoint(*this, *breakpoint_sp));
+AddBreakpoint(std::move(new_bp), false);
   }
 
   for (auto bp_name_entry : target->m_breakpoint_names) {

diff  --git 
a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
 
b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
index 9f0ba1116867..b0b04119a4f0 100644
--- 
a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
+++ 
b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
@@ -40,8 +40,21 @@ def test_bad_command_lines(self):
 self.build()
 self.do_test_bad_options()
 
+@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")
+def test_cop

[Lldb-commits] [lldb] 7fb0679 - [lldb][NFC] Remove unused parameter

2020-02-18 Thread Tatyana Krasnukha via lldb-commits

Author: Tatyana Krasnukha
Date: 2020-02-18T13:49:08+03:00
New Revision: 7fb06796abfd54878378b65456d567169d409bb3

URL: 
https://github.com/llvm/llvm-project/commit/7fb06796abfd54878378b65456d567169d409bb3
DIFF: 
https://github.com/llvm/llvm-project/commit/7fb06796abfd54878378b65456d567169d409bb3.diff

LOG: [lldb][NFC] Remove unused parameter

Rename search-filter's CopyForBreakpoint to CreateCopy, since they don't
do anything with breakpoints.

Added: 


Modified: 
lldb/include/lldb/Core/SearchFilter.h
lldb/include/lldb/Target/LanguageRuntime.h
lldb/source/Breakpoint/Breakpoint.cpp
lldb/source/Core/SearchFilter.cpp
lldb/source/Target/LanguageRuntime.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/SearchFilter.h 
b/lldb/include/lldb/Core/SearchFilter.h
index 8846ec0cf922..178489a88f3d 100644
--- a/lldb/include/lldb/Core/SearchFilter.h
+++ b/lldb/include/lldb/Core/SearchFilter.h
@@ -187,7 +187,7 @@ class SearchFilter {
   /// Standard "Dump" method.  At present it does nothing.
   virtual void Dump(Stream *s) const;
 
-  lldb::SearchFilterSP CopyForBreakpoint(Breakpoint &breakpoint);
+  lldb::SearchFilterSP CreateCopy(lldb::TargetSP& target_sp);
 
   static lldb::SearchFilterSP
   CreateFromStructuredData(const lldb::TargetSP& target_sp,
@@ -261,13 +261,13 @@ class SearchFilter {
const SymbolContext &context,
Searcher &searcher);
 
-  virtual lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) = 0;
+  virtual lldb::SearchFilterSP DoCreateCopy() = 0;
 
   void SetTarget(lldb::TargetSP &target_sp) { m_target_sp = target_sp; }
 
-  lldb::TargetSP
-  m_target_sp; // Every filter has to be associated with a target for
-   // now since you need a starting place for the search.
+  lldb::TargetSP m_target_sp; // Every filter has to be associated with
+  // a target for now since you need a starting
+  // place for the search.
 private:
   unsigned char SubclassID;
 };
@@ -295,7 +295,7 @@ class SearchFilterForUnconstrainedSearches : public 
SearchFilter {
   StructuredData::ObjectSP SerializeToStructuredData() override;
 
 protected:
-  lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
+  lldb::SearchFilterSP DoCreateCopy() override;
 };
 
 /// \class SearchFilterByModule SearchFilter.h "lldb/Core/SearchFilter.h" This
@@ -341,7 +341,7 @@ class SearchFilterByModule : public SearchFilter {
   StructuredData::ObjectSP SerializeToStructuredData() override;
 
 protected:
-  lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
+  lldb::SearchFilterSP DoCreateCopy() override;
 
 private:
   FileSpec m_module_spec;
@@ -394,7 +394,7 @@ class SearchFilterByModuleList : public SearchFilter {
   void SerializeUnwrapped(StructuredData::DictionarySP &options_dict_sp);
 
 protected:
-  lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
+  lldb::SearchFilterSP DoCreateCopy() override;
 
 protected:
   FileSpecList m_module_spec_list;
@@ -432,7 +432,7 @@ class SearchFilterByModuleListAndCU : public 
SearchFilterByModuleList {
   StructuredData::ObjectSP SerializeToStructuredData() override;
 
 protected:
-  lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
+  lldb::SearchFilterSP DoCreateCopy() override;
 
 private:
   FileSpecList m_cu_spec_list;

diff  --git a/lldb/include/lldb/Target/LanguageRuntime.h 
b/lldb/include/lldb/Target/LanguageRuntime.h
index aa132d35c0dd..2a792fe519d0 100644
--- a/lldb/include/lldb/Target/LanguageRuntime.h
+++ b/lldb/include/lldb/Target/LanguageRuntime.h
@@ -51,7 +51,7 @@ class ExceptionSearchFilter : public SearchFilter {
   LanguageRuntime *m_language_runtime;
   lldb::SearchFilterSP m_filter_sp;
 
-  lldb::SearchFilterSP DoCopyForBreakpoint(Breakpoint &breakpoint) override;
+  lldb::SearchFilterSP DoCreateCopy() override;
 
   void UpdateModuleListIfNeeded();
 };

diff  --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index 09122cfc2bfa..ec6700ea2bb1 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -74,7 +74,7 @@ BreakpointSP Breakpoint::CopyFromBreakpoint(TargetSP 
new_target,
   BreakpointSP bp(new Breakpoint(*new_target, bp_to_copy_from));
   // Now go through and copy the filter & resolver:
   bp->m_resolver_sp = bp_to_copy_from.m_resolver_sp->CopyForBreakpoint(*bp);
-  bp->m_filter_sp = bp_to_copy_from.m_filter_sp->CopyForBreakpoint(*bp);
+  bp->m_filter_sp = bp_to_copy_from.m_filter_sp->CreateCopy(new_target);
   return bp;
 }
 

diff  --git a/lldb/source/Core/SearchFilter.cpp 
b/lldb/source/Core/SearchFilter.cpp
index a42fa968656f..494e88dde267 100644
--- a/lldb/source/Core/SearchFilter.cpp
+++ b/lldb/source/Core/Sear

[Lldb-commits] [lldb] b624b7d - [lldb] Make shared_from_this-related code safer

2020-02-18 Thread Tatyana Krasnukha via lldb-commits

Author: Tatyana Krasnukha
Date: 2020-02-18T13:49:07+03:00
New Revision: b624b7dfd087809fb58bff0737750e75375fe450

URL: 
https://github.com/llvm/llvm-project/commit/b624b7dfd087809fb58bff0737750e75375fe450
DIFF: 
https://github.com/llvm/llvm-project/commit/b624b7dfd087809fb58bff0737750e75375fe450.diff

LOG: [lldb] Make shared_from_this-related code safer

Pass TargetSP to filters' CreateFromStructuredData, don't let them guess
whether target object is managed by a shared_ptr.

Make Breakpoint sure that m_target.shared_from_this() is safe by passing 
TargetSP
to all its static Create*** member-functions. This should be enough, since 
Breakpoint's
constructors are private/protected and never called directly (except by Target 
itself).

Added: 


Modified: 
lldb/include/lldb/Breakpoint/Breakpoint.h
lldb/include/lldb/Core/SearchFilter.h
lldb/source/Breakpoint/Breakpoint.cpp
lldb/source/Core/SearchFilter.cpp
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/include/lldb/Breakpoint/Breakpoint.h 
b/lldb/include/lldb/Breakpoint/Breakpoint.h
index c48a0ad73d4e..bdff7772fc6b 100644
--- a/lldb/include/lldb/Breakpoint/Breakpoint.h
+++ b/lldb/include/lldb/Breakpoint/Breakpoint.h
@@ -142,7 +142,8 @@ class Breakpoint : public 
std::enable_shared_from_this,
 
   // Saving & restoring breakpoints:
   static lldb::BreakpointSP CreateFromStructuredData(
-  Target &target, StructuredData::ObjectSP &data_object_sp, Status &error);
+  lldb::TargetSP target_sp, StructuredData::ObjectSP &data_object_sp,
+  Status &error);
 
   static bool
   SerializedBreakpointMatchesNames(StructuredData::ObjectSP &bkpt_object_sp,
@@ -570,7 +571,7 @@ class Breakpoint : public 
std::enable_shared_from_this,
 
   // This one should only be used by Target to copy breakpoints from target to
   // target - primarily from the dummy target to prime new targets.
-  static lldb::BreakpointSP CopyFromBreakpoint(Target& new_target,
+  static lldb::BreakpointSP CopyFromBreakpoint(lldb::TargetSP new_target,
   const Breakpoint &bp_to_copy_from);
 
 protected:

diff  --git a/lldb/include/lldb/Core/SearchFilter.h 
b/lldb/include/lldb/Core/SearchFilter.h
index ab5dc962230f..8846ec0cf922 100644
--- a/lldb/include/lldb/Core/SearchFilter.h
+++ b/lldb/include/lldb/Core/SearchFilter.h
@@ -190,7 +190,7 @@ class SearchFilter {
   lldb::SearchFilterSP CopyForBreakpoint(Breakpoint &breakpoint);
 
   static lldb::SearchFilterSP
-  CreateFromStructuredData(Target &target,
+  CreateFromStructuredData(const lldb::TargetSP& target_sp,
const StructuredData::Dictionary &data_dict,
Status &error);
 
@@ -288,7 +288,7 @@ class SearchFilterForUnconstrainedSearches : public 
SearchFilter {
   bool ModulePasses(const lldb::ModuleSP &module_sp) override;
 
   static lldb::SearchFilterSP
-  CreateFromStructuredData(Target &target,
+  CreateFromStructuredData(const lldb::TargetSP& target_sp,
const StructuredData::Dictionary &data_dict,
Status &error);
 
@@ -334,7 +334,7 @@ class SearchFilterByModule : public SearchFilter {
   void Search(Searcher &searcher) override;
 
   static lldb::SearchFilterSP
-  CreateFromStructuredData(Target &target,
+  CreateFromStructuredData(const lldb::TargetSP& target_sp,
const StructuredData::Dictionary &data_dict,
Status &error);
 
@@ -385,7 +385,7 @@ class SearchFilterByModuleList : public SearchFilter {
   void Search(Searcher &searcher) override;
 
   static lldb::SearchFilterSP
-  CreateFromStructuredData(Target &target,
+  CreateFromStructuredData(const lldb::TargetSP& target_sp,
const StructuredData::Dictionary &data_dict,
Status &error);
 
@@ -425,7 +425,7 @@ class SearchFilterByModuleListAndCU : public 
SearchFilterByModuleList {
   void Search(Searcher &searcher) override;
 
   static lldb::SearchFilterSP
-  CreateFromStructuredData(Target &target,
+  CreateFromStructuredData(const lldb::TargetSP& target_sp,
const StructuredData::Dictionary &data_dict,
Status &error);
 

diff  --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index 39c6828d3f09..09122cfc2bfa 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -66,9 +66,12 @@ Breakpoint::Breakpoint(Target &new_target, const Breakpoint 
&source_bp)
 // Destructor
 Breakpoint::~Breakpoint() = default;
 
-BreakpointSP Breakpoint::CopyFromBreakpoint(Target& new_target,
+BreakpointSP Breakpoint::CopyFromBreakpoint(TargetSP new_target,
 const Breakpoint& bp_to_copy_from) {
-  BreakpointSP bp(new Breakpoint(new_target, bp_to_copy_from));
+  if (!new_target)
+return BreakpointSP();
+
+  BreakpointSP bp(n

[Lldb-commits] [PATCH] D74558: [lldb] Make shared_from_this-related code safer

2020-02-18 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha closed this revision.
tatyana-krasnukha added a comment.

Closed by commit b624b7dfd087 



Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74558



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


[Lldb-commits] [PATCH] D74556: [lldb] Don't call CopyForBreakpoint from a Breakpoint's constructor

2020-02-18 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha closed this revision.
tatyana-krasnukha added a comment.

Closed by commit 185ef697ef5c 



Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74556



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


[Lldb-commits] [PATCH] D74759: Treat RangeDataVector as an augmented BST

2020-02-18 Thread Unnar Freyr Erlendsson via Phabricator via lldb-commits
unnar created this revision.
unnar added reviewers: labath, teemperor.
Herald added subscribers: lldb-commits, JDevlieghere.
Herald added a project: LLDB.

Since RangeDataVector is assumed to always be sorted we can treat it as an 
flattened BST and augment it with additional information about the ranges 
belonging to each "subtree". By storing the maximum endpoint in every subtree 
we can query for intervals in O(log n) time.

Note: this is not a complete patch, I just wanted to put it out there and see 
how you feel about this. Also what kind of testing could and should be done for 
this.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D74759

Files:
  lldb/include/lldb/Utility/RangeMap.h

Index: lldb/include/lldb/Utility/RangeMap.h
===
--- lldb/include/lldb/Utility/RangeMap.h
+++ lldb/include/lldb/Utility/RangeMap.h
@@ -592,13 +592,17 @@
 struct RangeData : public Range {
   typedef T DataType;
 
+  B upper_bound;
   DataType data;
 
-  RangeData() : Range(), data() {}
+  RangeData() : Range(), upper_bound(), data() {}
 
-  RangeData(B base, S size) : Range(base, size), data() {}
+  RangeData(B base, S size) : Range(base, size), upper_bound(), data() {}
 
-  RangeData(B base, S size, DataType d) : Range(base, size), data(d) {}
+  RangeData(B base, S size, DataType d) : Range(base, size), upper_bound(), data(d) {}
+
+  RangeData(B base, S size, B ub, DataType d) : Range(base, size), upper_bound(ub),
+  data(d) {}
 };
 
 template  Entry;
   typedef llvm::SmallVector Collection;
 
-  RangeDataVector(Compare compare = Compare()) : m_compare(compare) {}
+  RangeDataVector(Compare compare = Compare()) : m_compare(compare), upper_bound_computed(false) {}
 
   ~RangeDataVector() = default;
 
-  void Append(const Entry &entry) { m_entries.push_back(entry); }
+  void Append(const Entry &entry) { m_entries.push_back(entry); upper_bound_computed = false; }
 
   void Sort() {
 if (m_entries.size() > 1)
@@ -627,11 +631,28 @@
});
   }
 
+  // We can treat the vector as a flattened BST, augmenting it with upper bounds (max of
+  // range endpoints) for every index allows us to query for intersections in O(log n) time.
+  void ComputeUpperBounds() {
+ComputeUpperBounds(0, m_entries.size() - 1);
+upper_bound_computed = true;
+  }
+
+  B ComputeUpperBounds(int lo, int hi) {
+if (lo > hi) return B();
+
+int mid = (lo + hi) / 2;
+auto entry = m_entries[mid];
+
+entry.upper_bound = std::max(entry.base + entry.size, std::max(ComputeUpperBounds(lo, mid - 1),
+  ComputeUpperBounds(mid + 1, hi)));
+
+return entry.upper_bound;
+  }
+
 #ifdef ASSERT_RANGEMAP_ARE_SORTED
   bool IsSorted() const {
 typename Collection::const_iterator pos, end, prev;
-// First we determine if we can combine any of the Entry objects so we
-// don't end up allocating and making a new collection for no reason
 for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end;
  prev = pos++) {
   if (prev != end && *pos < *prev)
@@ -677,7 +698,7 @@
 }
   }
 
-  void Clear() { m_entries.clear(); }
+  void Clear() { m_entries.clear(); upper_bound_computed = false; }
 
   bool IsEmpty() const { return m_entries.empty(); }
 
@@ -708,22 +729,41 @@
   }
 
   uint32_t FindEntryIndexesThatContain(B addr,
-   std::vector &indexes) const {
+   std::vector &indexes) {
 #ifdef ASSERT_RANGEMAP_ARE_SORTED
 assert(IsSorted());
 #endif
-// Search the entries until the first entry that has a larger base address
-// than `addr`. As m_entries is sorted by their base address, all following
-// entries can't contain `addr` as their base address is already larger.
-for (const auto &entry : m_entries) {
-  if (entry.Contains(addr))
-indexes.push_back(entry.data);
-  else if (entry.GetRangeBase() > addr)
-break;
-}
+if (!upper_bound_computed)
+  ComputeUpperBounds();
+
+FindEntryIndexesThatContain(addr, 0, m_entries.size(), indexes);
+
 return indexes.size();
   }
 
+  void FindEntryIndexesThatContain(B addr, int lo, int hi,
+   std::vector &indexes) {
+if (lo > hi) return;
+int mid = (lo + hi) / 2;
+auto entry = m_entries[mid];
+
+// addr is greater than the rightmost point of any interval below mid
+// so there are cannot be any matches.
+if (addr > entry.upper_bound) return;
+
+// Recursively search left subtree
+FindEntryIndexesThatContain(addr, lo, mid - 1, indexes);
+
+// If addr is smaller than the start of the current interval it
+// cannot contain it nor can any of its right subtree.
+if (addr < entry.base) return;
+
+if (entry.Contains(addr))
+  indexes.push_back(entry.data);
+
+FindEntryIndexesThatContain(addr, mid + 1, hi, indexes);
+  }
+
   Entry *FindEntryThatContains(B 

[Lldb-commits] [lldb] db23825 - [lldb][test] Remove expected failure decorator from test_copy_from_dummy_target (TestScriptedResolver)

2020-02-18 Thread Tatyana Krasnukha via lldb-commits

Author: Tatyana Krasnukha
Date: 2020-02-18T15:04:29+03:00
New Revision: db23825970b021d0b5302d43aa5355c295c133d9

URL: 
https://github.com/llvm/llvm-project/commit/db23825970b021d0b5302d43aa5355c295c133d9
DIFF: 
https://github.com/llvm/llvm-project/commit/db23825970b021d0b5302d43aa5355c295c133d9.diff

LOG: [lldb][test] Remove expected failure decorator from 
test_copy_from_dummy_target (TestScriptedResolver)

This test case doesn't check that breakpoint's locations are resolved, and it 
passes on Windows too.

Added: 


Modified: 

lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
 
b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
index b0b04119a4f0..02c0aab9149e 100644
--- 
a/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
+++ 
b/lldb/test/API/functionalities/breakpoint/scripted_bkpt/TestScriptedResolver.py
@@ -40,7 +40,6 @@ def test_bad_command_lines(self):
 self.build()
 self.do_test_bad_options()
 
-@expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24528")
 def test_copy_from_dummy_target(self):
 """Make sure we don't crash during scripted breakpoint copy from dummy 
target"""
 self.build()



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


Re: [Lldb-commits] [PATCH] D74556: [lldb] Don't call CopyForBreakpoint from a Breakpoint's constructor

2020-02-18 Thread Raphael “Teemperor” Isemann via lldb-commits
I assume this is causing the test to fail on Windows? 
http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/13896

> On 18. Feb 2020, at 12:26, Tatyana Krasnukha via Phabricator 
>  wrote:
> 
> tatyana-krasnukha closed this revision.
> tatyana-krasnukha added a comment.
> 
> Closed by commit 185ef697ef5c 
> 
> 
> 
> Repository:
>  rLLDB LLDB
> 
> CHANGES SINCE LAST ACTION
>  https://reviews.llvm.org/D74556/new/
> 
> https://reviews.llvm.org/D74556
> 
> 
> 

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


Re: [Lldb-commits] [PATCH] D74556: [lldb] Don't call CopyForBreakpoint from a Breakpoint's constructor

2020-02-18 Thread Tatyana Krasnukha via lldb-commits
The test was passing unexpectedly, I already removed XFAIL decorator.

-Original Message-
From: Raphael “Teemperor” Isemann  
Sent: Tuesday, February 18, 2020 3:20 PM
To: reviews+d74556+public+411e87b2a9392...@reviews.llvm.org
Cc: Tatyana Krasnukha ; Jonas Devlieghere 
; jing...@apple.com; lldb-commits@lists.llvm.org; 
liburd1...@outlook.com; sani...@subpath.org; chi...@raincode.com
Subject: Re: [PATCH] D74556: [lldb] Don't call CopyForBreakpoint from a 
Breakpoint's constructor

I assume this is causing the test to fail on Windows? 
https://urldefense.proofpoint.com/v2/url?u=http-3A__lab.llvm.org-3A8011_builders_lldb-2Dx64-2Dwindows-2Dninja_builds_13896&d=DwIFAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=8NZfjV_ZLY_S7gZyQMq8mj7tiN4vlymPiSt0Wl0jegw&m=QVHIvP2O76mhlXu3NHpC60dV9plTxqLsbwE_fgLAJZk&s=jk0NPJjYvMlZIFBH2uPt1fo6zA543ZKEeBlU9108M_M&e=
 

> On 18. Feb 2020, at 12:26, Tatyana Krasnukha via Phabricator 
>  wrote:
> 
> tatyana-krasnukha closed this revision.
> tatyana-krasnukha added a comment.
> 
> Closed by commit 185ef697ef5c 
>   >
> 
> 
> Repository:
>  rLLDB LLDB
> 
> CHANGES SINCE LAST ACTION
>  
> https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D74556_new_&d=DwIFAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=8NZfjV_ZLY_S7gZyQMq8mj7tiN4vlymPiSt0Wl0jegw&m=QVHIvP2O76mhlXu3NHpC60dV9plTxqLsbwE_fgLAJZk&s=wjRYSdktS4jTXskJlmyc_cPVY0vx5rODphb2Q-TWpRI&e=
>  
> 
> https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D74556&d=DwIFAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=8NZfjV_ZLY_S7gZyQMq8mj7tiN4vlymPiSt0Wl0jegw&m=QVHIvP2O76mhlXu3NHpC60dV9plTxqLsbwE_fgLAJZk&s=eSiNRVypMo66Enyp_4OaR4YA1Bp_jSqCp92hhqUo3zI&e=
>  
> 
> 
> 

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


Re: [Lldb-commits] [PATCH] D74556: [lldb] Don't call CopyForBreakpoint from a Breakpoint's constructor

2020-02-18 Thread Raphael “Teemperor” Isemann via lldb-commits
Thanks!

> On Feb 18, 2020, at 1:24 PM, Tatyana Krasnukha 
>  wrote:
> 
> The test was passing unexpectedly, I already removed XFAIL decorator.
> 
> -Original Message-
> From: Raphael “Teemperor” Isemann  
> Sent: Tuesday, February 18, 2020 3:20 PM
> To: reviews+d74556+public+411e87b2a9392...@reviews.llvm.org
> Cc: Tatyana Krasnukha ; Jonas Devlieghere 
> ; jing...@apple.com; lldb-commits@lists.llvm.org; 
> liburd1...@outlook.com; sani...@subpath.org; chi...@raincode.com
> Subject: Re: [PATCH] D74556: [lldb] Don't call CopyForBreakpoint from a 
> Breakpoint's constructor
> 
> I assume this is causing the test to fail on Windows? 
> https://urldefense.proofpoint.com/v2/url?u=http-3A__lab.llvm.org-3A8011_builders_lldb-2Dx64-2Dwindows-2Dninja_builds_13896&d=DwIFAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=8NZfjV_ZLY_S7gZyQMq8mj7tiN4vlymPiSt0Wl0jegw&m=QVHIvP2O76mhlXu3NHpC60dV9plTxqLsbwE_fgLAJZk&s=jk0NPJjYvMlZIFBH2uPt1fo6zA543ZKEeBlU9108M_M&e=
>  
> 
>> On 18. Feb 2020, at 12:26, Tatyana Krasnukha via Phabricator 
>>  wrote:
>> 
>> tatyana-krasnukha closed this revision.
>> tatyana-krasnukha added a comment.
>> 
>> Closed by commit 185ef697ef5c 
>> >  >
>> 
>> 
>> Repository:
>> rLLDB LLDB
>> 
>> CHANGES SINCE LAST ACTION
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D74556_new_&d=DwIFAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=8NZfjV_ZLY_S7gZyQMq8mj7tiN4vlymPiSt0Wl0jegw&m=QVHIvP2O76mhlXu3NHpC60dV9plTxqLsbwE_fgLAJZk&s=wjRYSdktS4jTXskJlmyc_cPVY0vx5rODphb2Q-TWpRI&e=
>>  
>> 
>> https://urldefense.proofpoint.com/v2/url?u=https-3A__reviews.llvm.org_D74556&d=DwIFAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=8NZfjV_ZLY_S7gZyQMq8mj7tiN4vlymPiSt0Wl0jegw&m=QVHIvP2O76mhlXu3NHpC60dV9plTxqLsbwE_fgLAJZk&s=eSiNRVypMo66Enyp_4OaR4YA1Bp_jSqCp92hhqUo3zI&e=
>>  
>> 
>> 
>> 
> 

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


[Lldb-commits] [lldb] 40b2c7f - [lldb] Fix another instance where we pass a nullptr as TypeSourceInfo to NonTypeTemplateParmDecl::Create

2020-02-18 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2020-02-18T13:25:31+01:00
New Revision: 40b2c7f29b44e3c3e171a04593ac650aaf7c6ae6

URL: 
https://github.com/llvm/llvm-project/commit/40b2c7f29b44e3c3e171a04593ac650aaf7c6ae6
DIFF: 
https://github.com/llvm/llvm-project/commit/40b2c7f29b44e3c3e171a04593ac650aaf7c6ae6.diff

LOG: [lldb] Fix another instance where we pass a nullptr as TypeSourceInfo to 
NonTypeTemplateParmDecl::Create

Summary:
Follow up to an issue pointed out in the review of D73808. We shouldn't just 
pass in a nullptr TypeSourceInfo
in case Clang decided to access it.

Reviewers: shafik, vsk

Reviewed By: shafik, vsk

Subscribers: kristof.beyls, JDevlieghere, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D73946

Added: 


Modified: 
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 275911a76fb6..4092dc6ff78f 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1298,11 +1298,13 @@ static TemplateParameterList 
*CreateTemplateParameterList(
 
 if (!template_param_infos.packed_args->args.empty() &&
 IsValueParam(template_param_infos.packed_args->args[0])) {
+  QualType template_param_type =
+  template_param_infos.packed_args->args[0].getIntegralType();
   template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
   ast, decl_context, SourceLocation(), SourceLocation(), depth,
-  num_template_params, identifier_info,
-  template_param_infos.packed_args->args[0].getIntegralType(),
-  parameter_pack_true, nullptr));
+  num_template_params, identifier_info, template_param_type,
+  parameter_pack_true,
+  ast.getTrivialTypeSourceInfo(template_param_type)));
 } else {
   template_param_decls.push_back(TemplateTypeParmDecl::Create(
   ast, decl_context, SourceLocation(), SourceLocation(), depth,



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


[Lldb-commits] [PATCH] D74478: [lldb] Let TypeSystemClang::GetDisplayTypeName remove anonymous and inline namespaces.

2020-02-18 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor added a comment.

In D74478#1874746 , @jingham wrote:

> The only hesitation I have about this is if we are still printing this noise 
> in demangled names, then the name of the type you see for a variable will be 
> different from what you see when a method of that type ends up in a 
> backtrace.  That might be confusing.  OTOH, the correct solution to that 
> problem, IMO, is to remove the noise from backtraces, not keep it in the 
> types...


I'm not entirely sure how/if we can make the backtraces nicer as we only have 
the function type (but not the specific function declaration with the name) and 
mangled/demangled name for them. Removing the `anonymous namespace` from the 
backtrace is doable with that, but inline namespaces and default template 
arguments (which are part of the radar) aren't possible unless we start doing 
much more work for the backtraces and figure out the actual FunctionDecls 
behind each function.

FWIW, the current way we express backtraces is anyway not identical to what we 
show in variables. Any typedefs and so on are lost in the mangled name, so 
stepping into `std::string` member functions brings users to a backtrace with 
in `std::__1::basic_string, 
std::__1::allocator >::foo`. However printing the string shows them 
`std::__1::string`.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74478



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


[Lldb-commits] [PATCH] D73946: [lldb] Fix another instance where we pass a nullptr as TypeSourceInfo to NonTypeTemplateParmDecl::Create

2020-02-18 Thread Raphael Isemann via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG40b2c7f29b44: [lldb] Fix another instance where we pass a 
nullptr as TypeSourceInfo to… (authored by teemperor).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D73946

Files:
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp


Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1298,11 +1298,13 @@
 
 if (!template_param_infos.packed_args->args.empty() &&
 IsValueParam(template_param_infos.packed_args->args[0])) {
+  QualType template_param_type =
+  template_param_infos.packed_args->args[0].getIntegralType();
   template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
   ast, decl_context, SourceLocation(), SourceLocation(), depth,
-  num_template_params, identifier_info,
-  template_param_infos.packed_args->args[0].getIntegralType(),
-  parameter_pack_true, nullptr));
+  num_template_params, identifier_info, template_param_type,
+  parameter_pack_true,
+  ast.getTrivialTypeSourceInfo(template_param_type)));
 } else {
   template_param_decls.push_back(TemplateTypeParmDecl::Create(
   ast, decl_context, SourceLocation(), SourceLocation(), depth,


Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -1298,11 +1298,13 @@
 
 if (!template_param_infos.packed_args->args.empty() &&
 IsValueParam(template_param_infos.packed_args->args[0])) {
+  QualType template_param_type =
+  template_param_infos.packed_args->args[0].getIntegralType();
   template_param_decls.push_back(NonTypeTemplateParmDecl::Create(
   ast, decl_context, SourceLocation(), SourceLocation(), depth,
-  num_template_params, identifier_info,
-  template_param_infos.packed_args->args[0].getIntegralType(),
-  parameter_pack_true, nullptr));
+  num_template_params, identifier_info, template_param_type,
+  parameter_pack_true,
+  ast.getTrivialTypeSourceInfo(template_param_type)));
 } else {
   template_param_decls.push_back(TemplateTypeParmDecl::Create(
   ast, decl_context, SourceLocation(), SourceLocation(), depth,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74759: Treat RangeDataVector as an augmented BST

2020-02-18 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin added a comment.

Thanks for putting this together, some comments below. Let us see what Pavel 
thinks.




Comment at: lldb/include/lldb/Utility/RangeMap.h:634
 
+  // We can treat the vector as a flattened BST, augmenting it with upper 
bounds (max of
+  // range endpoints) for every index allows us to query for intersections in 
O(log n) time.

BST -> binary search tree



Comment at: lldb/include/lldb/Utility/RangeMap.h:642
+  B ComputeUpperBounds(int lo, int hi) {
+if (lo > hi) return B();
+

Here, B() should be the min value of type B, no? Perhaps this should be 
`std::numeric_limits::min()` instead of `B()`?



Comment at: lldb/include/lldb/Utility/RangeMap.h:745
+  void FindEntryIndexesThatContain(B addr, int lo, int hi,
+   std::vector &indexes) {
+if (lo > hi) return;

Hmm, weird, I am surprised this is not `std::vector &indexes` (I realize 
this was in the code before).



Comment at: lldb/include/lldb/Utility/RangeMap.h:849
   Compare m_compare;
+  bool upper_bound_computed;
 };

I am guessing this should have the `m_` prefix?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74759



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


[Lldb-commits] [lldb] a82d3e8 - Reland "[DebugInfo] Enable the debug entry values feature by default"

2020-02-18 Thread Djordje Todorovic via lldb-commits

Author: Djordje Todorovic
Date: 2020-02-18T14:41:08+01:00
New Revision: a82d3e8a6e67473c94a5ce6345372748e9b61718

URL: 
https://github.com/llvm/llvm-project/commit/a82d3e8a6e67473c94a5ce6345372748e9b61718
DIFF: 
https://github.com/llvm/llvm-project/commit/a82d3e8a6e67473c94a5ce6345372748e9b61718.diff

LOG: Reland "[DebugInfo] Enable the debug entry values feature by default"

This patch enables the debug entry values feature.

  - Remove the (CC1) experimental -femit-debug-entry-values option
  - Enable it for x86, arm and aarch64 targets
  - Resolve the test failures
  - Leave the llc experimental option for targets that do not
support the CallSiteInfo yet

Differential Revision: https://reviews.llvm.org/D73534

Added: 
llvm/test/DebugInfo/X86/no-entry-values-with-O0.ll

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/CC1Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/debug-info-extern-call.c
clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
lldb/packages/Python/lldbsuite/test/decorators.py

lldb/test/API/functionalities/param_entry_vals/basic_entry_values_x86_64/Makefile
llvm/include/llvm/CodeGen/CommandFlags.inc
llvm/include/llvm/Target/TargetMachine.h
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/lib/CodeGen/LiveDebugValues.cpp
llvm/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/lib/CodeGen/MachineFunction.cpp
llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
llvm/lib/CodeGen/TargetOptionsImpl.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/ARM/ARMTargetMachine.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86TargetMachine.cpp
llvm/test/CodeGen/AArch64/arm64-anyregcc.ll
llvm/test/CodeGen/AArch64/arm64-patchpoint.ll
llvm/test/CodeGen/AArch64/arm64-tls-dynamics.ll
llvm/test/CodeGen/ARM/smml.ll
llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error1.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error2.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error3.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error4.mir
llvm/test/CodeGen/X86/call-site-info-output.ll
llvm/test/CodeGen/X86/hoist-invariant-load.ll
llvm/test/CodeGen/X86/speculative-load-hardening-indirect.ll
llvm/test/CodeGen/X86/statepoint-allocas.ll
llvm/test/CodeGen/X86/tail-dup-repeat.ll
llvm/test/CodeGen/X86/xray-custom-log.ll
llvm/test/CodeGen/X86/xray-typed-event-log.ll
llvm/test/DebugInfo/AArch64/call-site-info-output.ll
llvm/test/DebugInfo/ARM/call-site-info-output.ll
llvm/test/DebugInfo/ARM/entry-value-multi-byte-expr.ll
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpret-movzxi.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir
llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir
llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg-multiple-defs.mir
llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reg-shuffle.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
llvm/test/DebugInfo/MIR/X86/kill-entry-value-after-diamond-bbs.mir
llvm/test/DebugInfo/MIR/X86/multiple-param-dbg-value-entry.mir
llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
llvm/test/DebugInfo/Sparc/entry-value-complex-reg-expr.ll
llvm/test/DebugInfo/X86/dbg-value-range.ll
llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll
llvm/test

[Lldb-commits] [PATCH] D74759: Treat RangeDataVector as an augmented BST

2020-02-18 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

I like this idea a lot, in principle. It is much simpler than a full blown 
interval tree, and it should give us similar performance characteristics.

Have you done a proper complexity analysis here? I doubt the `O(log n)` claim 
is true in general. It would have to be at least `O(m + log n)` (m - number of 
elements found), but it's not clear to me whether even this is true in general. 
(However, I believe this can achieve ~~log(n) for non-degenerate cases.)

The implementation itself needs some work though. My incomplete list of 
comments is:

- replace `int` with `size_t` and closed intervals with half-open ones
- let's move the computation of the upper bound into the "Sort" function. 
sorting is O(n log(n)), this is O(n) -- we can just hide it there.
- make private functions private
- we should avoid the business of figuring out what is the suitable "minimum" 
value of B by ensuring we call the recursive function on non-empty intervals
- clang-format the patch

For testing you should add some c++ unit tests for the relevant interfaces.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74759



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


[Lldb-commits] [lldb] b807a28 - [lldb] Merge RangeArray and RangeVector

2020-02-18 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2020-02-18T15:22:55+01:00
New Revision: b807a28787638f36a907f6f3ee832b840d1be08c

URL: 
https://github.com/llvm/llvm-project/commit/b807a28787638f36a907f6f3ee832b840d1be08c
DIFF: 
https://github.com/llvm/llvm-project/commit/b807a28787638f36a907f6f3ee832b840d1be08c.diff

LOG: [lldb] Merge RangeArray and RangeVector

The two classes are equivalent, except:
- the former uses a llvm::SmallVector (with a configurable size), while
  the latter uses std::vector.
- the former has a typo in one of the functions name

This patch just leaves one class, using llvm::SmallVector, and defaults
the small size to zero. This is the same thing we did with the
RangeDataVector class in D56170.

Added: 


Modified: 
lldb/include/lldb/Core/dwarf.h
lldb/include/lldb/Symbol/Block.h
lldb/include/lldb/Symbol/LineTable.h
lldb/include/lldb/Target/Memory.h
lldb/include/lldb/Utility/RangeMap.h
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
lldb/source/Target/Memory.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/dwarf.h b/lldb/include/lldb/Core/dwarf.h
index 7f46f715cf0c..cd9cf249bc63 100644
--- a/lldb/include/lldb/Core/dwarf.h
+++ b/lldb/include/lldb/Core/dwarf.h
@@ -71,6 +71,6 @@ typedef uint32_t dw_offset_t; // Dwarf Debug Information 
Entry offset for any
 //#define DW_OP_APPLE_error 0xFF // Stops expression evaluation and
 //returns an error (no args)
 
-typedef lldb_private::RangeArray DWARFRangeList;
+typedef lldb_private::RangeVector DWARFRangeList;
 
 #endif // LLDB_CORE_DWARF_H

diff  --git a/lldb/include/lldb/Symbol/Block.h 
b/lldb/include/lldb/Symbol/Block.h
index 8c1b5a83e647..802f362a72f0 100644
--- a/lldb/include/lldb/Symbol/Block.h
+++ b/lldb/include/lldb/Symbol/Block.h
@@ -40,7 +40,7 @@ namespace lldb_private {
 /// blocks.
 class Block : public UserID, public SymbolContextScope {
 public:
-  typedef RangeArray RangeList;
+  typedef RangeVector RangeList;
   typedef RangeList::Entry Range;
 
   /// Construct with a User ID \a uid, \a depth.

diff  --git a/lldb/include/lldb/Symbol/LineTable.h 
b/lldb/include/lldb/Symbol/LineTable.h
index 1b01660a2c3e..d7360c92c067 100644
--- a/lldb/include/lldb/Symbol/LineTable.h
+++ b/lldb/include/lldb/Symbol/LineTable.h
@@ -183,7 +183,7 @@ class LineTable {
   /// The number of line table entries in this line table.
   uint32_t GetSize() const;
 
-  typedef lldb_private::RangeArray
+  typedef lldb_private::RangeVector
   FileAddressRanges;
 
   /// Gets all contiguous file address ranges for the entire line table.

diff  --git a/lldb/include/lldb/Target/Memory.h 
b/lldb/include/lldb/Target/Memory.h
index 28dd3e9d92e4..b1b190801ea3 100644
--- a/lldb/include/lldb/Target/Memory.h
+++ b/lldb/include/lldb/Target/Memory.h
@@ -45,7 +45,7 @@ class MemoryCache {
 
 protected:
   typedef std::map BlockMap;
-  typedef RangeArray InvalidRanges;
+  typedef RangeVector InvalidRanges;
   typedef Range AddrRange;
   // Classes that inherit from MemoryCache can see and modify these
   std::recursive_mutex m_mutex;

diff  --git a/lldb/include/lldb/Utility/RangeMap.h 
b/lldb/include/lldb/Utility/RangeMap.h
index 9e0307351836..53fb691323a6 100644
--- a/lldb/include/lldb/Utility/RangeMap.h
+++ b/lldb/include/lldb/Utility/RangeMap.h
@@ -122,220 +122,13 @@ template  struct Range {
   }
 };
 
-// A range array class where you get to define the type of the ranges
-// that the collection contains.
-
-template  class RangeArray {
+template  class RangeVector {
 public:
   typedef B BaseType;
   typedef S SizeType;
   typedef Range Entry;
   typedef llvm::SmallVector Collection;
 
-  RangeArray() = default;
-
-  ~RangeArray() = default;
-
-  void Append(const Entry &entry) { m_entries.push_back(entry); }
-
-  void Append(B base, S size) { m_entries.emplace_back(base, size); }
-
-  bool RemoveEntrtAtIndex(uint32_t idx) {
-if (idx < m_entries.size()) {
-  m_entries.erase(m_entries.begin() + idx);
-  return true;
-}
-return false;
-  }
-
-  void Sort() {
-if (m_entries.size() > 1)
-  std::stable_sort(m_entries.begin(), m_entries.end());
-  }
-
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
-  bool IsSorted() const {
-typename Collection::const_iterator pos, end, prev;
-for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != 
end;
- prev = pos++) {
-  if (prev != end && *pos < *prev)
-return false;
-}
-return true;
-  }
-#endif
-
-  void CombineConsecutiveRanges() {
-#ifdef ASSERT_RANGEMAP_ARE_SORTED
-assert(IsSorted());
-#endif
-// Can't combine if ranges if we have zero or one range
-if (m_entries.size() > 1) {
-  // The list should be sorted prior to calling this function
-  typename Collection::iterator pos;
-  typename Collection::iterator end;
-  typename Collection::iterator prev;
-  bool can_combine = false;
-  // First we determine 

[Lldb-commits] [PATCH] D74759: Treat RangeDataVector as an augmented BST

2020-02-18 Thread Jaroslav Sevcik via Phabricator via lldb-commits
jarin added a comment.

In D74759#1880499 , @labath wrote:

> I like this idea a lot, in principle. It is much simpler than a full blown 
> interval tree, and it should give us similar performance characteristics.
>
> Have you done a proper complexity analysis here? I doubt the `O(log n)` claim 
> is true in general. It would have to be at least `O(m + log n)` (m - number 
> of elements found), but it's not clear to me whether even this is true in 
> general. (However, I believe this can achieve ~~log(n) for non-degenerate 
> cases.)


Thanks for the feedback! We were aiming for something simple and efficient 
enough. Our preliminary results show that the lookup pretty much disappears 
even from the profiles it was dominating before.

The implementation is pretty much taken from the "Augmented tree" section of 
https://en.wikipedia.org/wiki/Interval_tree where we just use the tree induced 
by the pivots of the binary search as the binary search tree that we augment. I 
believe the complexity is O(m log n), even though the wikipedia article makes a 
O(m + log n) claim. This should be still much better than the current O(n) and 
the memory cost seems to be quite palatable (extra word per symbol).

> The implementation itself needs some work though. My incomplete list of 
> comments is:
> 
> - replace `int` with `size_t` and closed intervals with half-open ones
> - let's move the computation of the upper bound into the "Sort" function. 
> sorting is O(n log(n)), this is O(n) -- we can just hide it there.
> - make private functions private
> - we should avoid the business of figuring out what is the suitable "minimum" 
> value of B by ensuring we call the recursive function on non-empty intervals
> - clang-format the patch
> 
>   For testing you should add some c++ unit tests for the relevant interfaces.




Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74759



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


[Lldb-commits] [lldb] 2bf44d1 - Revert "Reland "[DebugInfo] Enable the debug entry values feature by default""

2020-02-18 Thread Djordje Todorovic via lldb-commits

Author: Djordje Todorovic
Date: 2020-02-18T16:38:11+01:00
New Revision: 2bf44d11cb42a952bdeb778210d8b3e737f0b96e

URL: 
https://github.com/llvm/llvm-project/commit/2bf44d11cb42a952bdeb778210d8b3e737f0b96e
DIFF: 
https://github.com/llvm/llvm-project/commit/2bf44d11cb42a952bdeb778210d8b3e737f0b96e.diff

LOG: Revert "Reland "[DebugInfo] Enable the debug entry values feature by 
default""

This reverts commit rGa82d3e8a6e67.

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/CC1Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/debug-info-extern-call.c
clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
lldb/packages/Python/lldbsuite/test/decorators.py

lldb/test/API/functionalities/param_entry_vals/basic_entry_values_x86_64/Makefile
llvm/include/llvm/CodeGen/CommandFlags.inc
llvm/include/llvm/Target/TargetMachine.h
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/lib/CodeGen/LiveDebugValues.cpp
llvm/lib/CodeGen/MIRParser/MIRParser.cpp
llvm/lib/CodeGen/MachineFunction.cpp
llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
llvm/lib/CodeGen/TargetOptionsImpl.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/ARM/ARMTargetMachine.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86TargetMachine.cpp
llvm/test/CodeGen/AArch64/arm64-anyregcc.ll
llvm/test/CodeGen/AArch64/arm64-patchpoint.ll
llvm/test/CodeGen/AArch64/arm64-tls-dynamics.ll
llvm/test/CodeGen/ARM/smml.ll
llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error1.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error2.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error3.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error4.mir
llvm/test/CodeGen/X86/call-site-info-output.ll
llvm/test/CodeGen/X86/hoist-invariant-load.ll
llvm/test/CodeGen/X86/speculative-load-hardening-indirect.ll
llvm/test/CodeGen/X86/statepoint-allocas.ll
llvm/test/CodeGen/X86/tail-dup-repeat.ll
llvm/test/CodeGen/X86/xray-custom-log.ll
llvm/test/CodeGen/X86/xray-typed-event-log.ll
llvm/test/DebugInfo/AArch64/call-site-info-output.ll
llvm/test/DebugInfo/ARM/call-site-info-output.ll
llvm/test/DebugInfo/ARM/entry-value-multi-byte-expr.ll
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpret-movzxi.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir
llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir
llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg-multiple-defs.mir
llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reg-shuffle.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
llvm/test/DebugInfo/MIR/X86/kill-entry-value-after-diamond-bbs.mir
llvm/test/DebugInfo/MIR/X86/multiple-param-dbg-value-entry.mir
llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
llvm/test/DebugInfo/Sparc/entry-value-complex-reg-expr.ll
llvm/test/DebugInfo/X86/dbg-value-range.ll
llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll
llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
llvm/test/DebugInfo/X86/loclists-dwp.ll
llvm/test/tools/llvm-dwarfdump/X86/locstats.ll
llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll
llvm/test/tools/llvm-dwarfdump/X86/valid-call-site-GNU-extensions.ll
llvm/test

[Lldb-commits] [PATCH] D74217: Add target.xml support for qXfer request.

2020-02-18 Thread Levon Ter-Grigoryan via Phabricator via lldb-commits
PatriosTheGreat updated this revision to Diff 245167.
PatriosTheGreat added a comment.

In this revision I fix value_regnums and invalidate_regnums serialization in 
target.xml.
However I'm not so sure that this is the cause of problem with ARM tests.

>From tests log it seems like there are some unexpected value in register.
Is it possible to get logs output from this test run 
http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/1713/steps/test/logs/stdio
 that would help us a lot to fix it.


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

https://reviews.llvm.org/D74217

Files:
  
lldb/packages/Python/lldbsuite/test/tools/lldb-server/registers-target-xml-reading/Makefile
  
lldb/packages/Python/lldbsuite/test/tools/lldb-server/registers-target-xml-reading/TestGdbRemoteTargetXmlPacket.py
  
lldb/packages/Python/lldbsuite/test/tools/lldb-server/registers-target-xml-reading/main.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h

Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
@@ -199,6 +199,8 @@
   static std::string XMLEncodeAttributeValue(llvm::StringRef value);
 
 private:
+  llvm::Expected> BuildTargetXml();
+
   void HandleInferiorState_Exited(NativeProcessProtocol *process);
 
   void HandleInferiorState_Stopped(NativeProcessProtocol *process);
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -377,6 +377,99 @@
   }
 }
 
+static llvm::StringRef GetEncodingNameOrEmpty(const RegisterInfo ®_info) {
+  switch (reg_info.encoding) {
+  case eEncodingUint:
+return "uint";
+  case eEncodingSint:
+return "sint";
+  case eEncodingIEEE754:
+return "ieee754";
+  case eEncodingVector:
+return "vector";
+  default:
+return "";
+  }
+}
+
+static llvm::StringRef GetFormatNameOrEmpty(const RegisterInfo ®_info) {
+  switch (reg_info.format) {
+  case eFormatBinary:
+return "binary";
+  case eFormatDecimal:
+return "decimal";
+  case eFormatHex:
+return "hex";
+  case eFormatFloat:
+return "float";
+  case eFormatVectorOfSInt8:
+return "vector-sint8";
+  case eFormatVectorOfUInt8:
+return "vector-uint8";
+  case eFormatVectorOfSInt16:
+return "vector-sint16";
+  case eFormatVectorOfUInt16:
+return "vector-uint16";
+  case eFormatVectorOfSInt32:
+return "vector-sint32";
+  case eFormatVectorOfUInt32:
+return "vector-uint32";
+  case eFormatVectorOfFloat32:
+return "vector-float32";
+  case eFormatVectorOfUInt64:
+return "vector-uint64";
+  case eFormatVectorOfUInt128:
+return "vector-uint128";
+  default:
+return "";
+  };
+}
+
+static llvm::StringRef GetKindGenericOrEmpty(const RegisterInfo ®_info) {
+  switch (reg_info.kinds[RegisterKind::eRegisterKindGeneric]) {
+  case LLDB_REGNUM_GENERIC_PC:
+return "pc";
+  case LLDB_REGNUM_GENERIC_SP:
+return "sp";
+  case LLDB_REGNUM_GENERIC_FP:
+return "fp";
+  case LLDB_REGNUM_GENERIC_RA:
+return "ra";
+  case LLDB_REGNUM_GENERIC_FLAGS:
+return "flags";
+  case LLDB_REGNUM_GENERIC_ARG1:
+return "arg1";
+  case LLDB_REGNUM_GENERIC_ARG2:
+return "arg2";
+  case LLDB_REGNUM_GENERIC_ARG3:
+return "arg3";
+  case LLDB_REGNUM_GENERIC_ARG4:
+return "arg4";
+  case LLDB_REGNUM_GENERIC_ARG5:
+return "arg5";
+  case LLDB_REGNUM_GENERIC_ARG6:
+return "arg6";
+  case LLDB_REGNUM_GENERIC_ARG7:
+return "arg7";
+  case LLDB_REGNUM_GENERIC_ARG8:
+return "arg8";
+  default:
+return "";
+  }
+}
+
+static void CollectRegNums(const uint32_t *reg_num, StreamString &response,
+   bool usehex) {
+  for (int i = 0; *reg_num != LLDB_INVALID_REGNUM; ++reg_num, ++i) {
+if (i > 0)
+  response.PutChar(',');
+if (usehex)
+  response.Printf("%" PRIx32, *reg_num);
+else
+  response.Printf("%" PRIu32, *reg_num);
+  }
+}
+
 static void WriteRegisterValueInHexFixedWidth(
 StreamString &response, NativeRegisterContext ®_ctx,
 const RegisterInfo ®_info, const RegisterValue *reg_value_p,
@@ -1699,74 +1792,18 @@
   response.Printf("bitsize:%" PRIu32 ";offset:%" PRIu32 ";",
   reg_info->byte_size * 8, reg_info->byte_offset);
 
-  switch (reg_info->encoding) {
-  case eEncodingUint:
-response.PutCString("encoding:uint;");
-break;
-  case eEncodingSint:
-response.PutCString("encoding:

[Lldb-commits] [lldb] aa3e99d - [lldb] [nfc] Separate DIERef vs. user_id_t: GetForwardDeclClangTypeToDie()

2020-02-18 Thread Jan Kratochvil via lldb-commits

Author: Jan Kratochvil
Date: 2020-02-18T18:09:39+01:00
New Revision: aa3e99dc859febba398925afeefb118403e15ab9

URL: 
https://github.com/llvm/llvm-project/commit/aa3e99dc859febba398925afeefb118403e15ab9
DIFF: 
https://github.com/llvm/llvm-project/commit/aa3e99dc859febba398925afeefb118403e15ab9.diff

LOG: [lldb] [nfc] Separate DIERef vs. user_id_t: GetForwardDeclClangTypeToDie()

Reasons are the same as for D74637.

Differential Revision: https://reviews.llvm.org/D74690

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 02f481684cd7..0ea3adceaecc 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1720,9 +1720,9 @@ DWARFASTParserClang::ParseStructureLikeDIE(const 
SymbolContext &sc,
   // binaries.
   dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] =
   clang_type.GetOpaqueQualType();
-  dwarf->GetForwardDeclClangTypeToDie()
-  [ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType()] =
-  die.GetID();
+  dwarf->GetForwardDeclClangTypeToDie().try_emplace(
+  ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType(),
+  *die.GetDIERef());
   m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), true);
 }
   }

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index d8165d718499..04be8f5e7349 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -322,8 +322,7 @@ class SymbolFileDWARF : public lldb_private::SymbolFile,
   typedef llvm::DenseMap
   DIEToClangType;
-  typedef llvm::DenseMap
-  ClangTypeToDIE;
+  typedef llvm::DenseMap ClangTypeToDIE;
 
   DISALLOW_COPY_AND_ASSIGN(SymbolFileDWARF);
 



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


[Lldb-commits] [PATCH] D74690: Separate DIERef vs. user_id_t: GetForwardDeclClangTypeToDie()

2020-02-18 Thread Jan Kratochvil via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaa3e99dc859f: [lldb] [nfc] Separate DIERef vs. user_id_t: 
GetForwardDeclClangTypeToDie() (authored by jankratochvil).

Changed prior to commit:
  https://reviews.llvm.org/D74690?vs=244976&id=245185#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74690

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -322,8 +322,7 @@
   typedef llvm::DenseMap
   DIEToClangType;
-  typedef llvm::DenseMap
-  ClangTypeToDIE;
+  typedef llvm::DenseMap ClangTypeToDIE;
 
   DISALLOW_COPY_AND_ASSIGN(SymbolFileDWARF);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1720,9 +1720,9 @@
   // binaries.
   dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] =
   clang_type.GetOpaqueQualType();
-  dwarf->GetForwardDeclClangTypeToDie()
-  [ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType()] =
-  die.GetID();
+  dwarf->GetForwardDeclClangTypeToDie().try_emplace(
+  ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType(),
+  *die.GetDIERef());
   m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), true);
 }
   }


Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -322,8 +322,7 @@
   typedef llvm::DenseMap
   DIEToClangType;
-  typedef llvm::DenseMap
-  ClangTypeToDIE;
+  typedef llvm::DenseMap ClangTypeToDIE;
 
   DISALLOW_COPY_AND_ASSIGN(SymbolFileDWARF);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -1720,9 +1720,9 @@
   // binaries.
   dwarf->GetForwardDeclDieToClangType()[die.GetDIE()] =
   clang_type.GetOpaqueQualType();
-  dwarf->GetForwardDeclClangTypeToDie()
-  [ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType()] =
-  die.GetID();
+  dwarf->GetForwardDeclClangTypeToDie().try_emplace(
+  ClangUtil::RemoveFastQualifiers(clang_type).GetOpaqueQualType(),
+  *die.GetDIERef());
   m_ast.SetHasExternalStorage(clang_type.GetOpaqueQualType(), true);
 }
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-18 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

It looks like this broke the windows lldb bot:

lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/13902


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

https://reviews.llvm.org/D73534



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


[Lldb-commits] [PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-18 Thread Djordje Todorovic via Phabricator via lldb-commits
djtodoro added a comment.

Thanks for reporting that, are you sure this was the cause of the failure? I'll 
revert this while investigate, but it does not seem to me this is related to 
this patch.


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

https://reviews.llvm.org/D73534



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


[Lldb-commits] [PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-18 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

In D73534#1880790 , @stella.stamenova 
wrote:

> I am not sure this was the cause of the failure, but other than your patches, 
> there was only one other change in the first failing build. I have not had 
> time to fully investigate yet.


It looks like the issue was fixed and it was not this change: 
http://lab.llvm.org:8011/builders/lldb-x64-windows-ninja/builds/13911

Thanks for looking into it!


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

https://reviews.llvm.org/D73534



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


[Lldb-commits] [PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-18 Thread Djordje Todorovic via Phabricator via lldb-commits
djtodoro updated this revision to Diff 245123.
djtodoro added a comment.

-Addressing the latest comments


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

https://reviews.llvm.org/D73534

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/debug-info-extern-call.c
  clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
  lldb/packages/Python/lldbsuite/test/decorators.py
  
lldb/test/API/functionalities/param_entry_vals/basic_entry_values_x86_64/Makefile
  llvm/include/llvm/CodeGen/CommandFlags.inc
  llvm/include/llvm/Target/TargetMachine.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
  llvm/lib/CodeGen/LiveDebugValues.cpp
  llvm/lib/CodeGen/MIRParser/MIRParser.cpp
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
  llvm/lib/CodeGen/TargetOptionsImpl.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMTargetMachine.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/ARM/smml.ll
  llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
  llvm/test/CodeGen/MIR/X86/call-site-info-error1.mir
  llvm/test/CodeGen/MIR/X86/call-site-info-error2.mir
  llvm/test/CodeGen/MIR/X86/call-site-info-error3.mir
  llvm/test/CodeGen/MIR/X86/call-site-info-error4.mir
  llvm/test/CodeGen/X86/call-site-info-output.ll
  llvm/test/CodeGen/X86/tail-dup-repeat.ll
  llvm/test/DebugInfo/AArch64/call-site-info-output.ll
  llvm/test/DebugInfo/ARM/call-site-info-output.ll
  llvm/test/DebugInfo/ARM/entry-value-multi-byte-expr.ll
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpret-movzxi.mir
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-interpretation.mir
  llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
  llvm/test/DebugInfo/MIR/ARM/dbgcall-site-interpretation.mir
  llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
  llvm/test/DebugInfo/MIR/ARM/if-coverter-call-site-info.mir
  llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
  llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
  llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
  llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
  llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir
  llvm/test/DebugInfo/MIR/X86/dbg-call-site-spilled-arg.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-reg-shuffle.mir
  llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
  llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
  llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
  llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
  llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
  llvm/test/DebugInfo/MIR/X86/kill-entry-value-after-diamond-bbs.mir
  llvm/test/DebugInfo/MIR/X86/multiple-param-dbg-value-entry.mir
  llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
  llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
  llvm/test/DebugInfo/Sparc/entry-value-complex-reg-expr.ll
  llvm/test/DebugInfo/X86/dbg-value-range.ll
  llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll
  llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
  llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
  llvm/test/DebugInfo/X86/loclists-dwp.ll
  llvm/test/DebugInfo/X86/no-entry-values-with-O0.ll
  llvm/test/tools/llvm-dwarfdump/X86/locstats.ll
  llvm/test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll
  llvm/test/tools/llvm-dwarfdump/X86/valid-call-site-GNU-extensions.ll
  llvm/test/tools/llvm-locstats/locstats.ll

Index: llvm/test/tools/llvm-locstats/locstats.ll
===
--- llvm/test/tools/llvm-locstats/locstats.ll
+++ llvm/test/tools/llvm-locstats/locstats.ll
@@ -9,9 +9,9 @@
 ; LOCSTATS: [10%,20%) 0 0%
 ; LOCSTATS: [20%,30%) 1 11%
 ; LOCSTATS: [30%,40%) 0 0%
-; LOCSTATS: [40%,50%) 1 11%
-; LOCSTATS: [50%,60%) 1 11%
-; LOCSTATS: [60%,70%) 1 11%
+; LOCSTATS: [40%,50%) 0 0%
+; LOCSTATS: [50%,60%) 0 0%
+; LOCSTATS: [60%,70%) 3 33%
 ; LOCSTATS: [70%,80%) 0 0%
 ; LOCSTATS: [80%,90%) 2 22%
 ; LOCSTATS: [90%,100%) 1 11%
Index: llvm/test/tools/llvm-dwarfdump/X86/valid-call-site-GNU-extensions.ll
===
--- llvm/test/tools/llvm-dwarfdump/X86/valid-call-site-GNU-extension

[Lldb-commits] [PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-18 Thread Stella Stamenova via Phabricator via lldb-commits
stella.stamenova added a comment.

I am not sure this was the cause of the failure, but other than your patches, 
there was only one other change in the first failing build. I have not had time 
to fully investigate yet.


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

https://reviews.llvm.org/D73534



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


[Lldb-commits] [PATCH] D73534: [DebugInfo] Enable the debug entry values feature by default

2020-02-18 Thread Djordje Todorovic via Phabricator via lldb-commits
djtodoro added a comment.

I’ve already reverted the patch, but I’ll reland it again tomorrow. Thanks.


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

https://reviews.llvm.org/D73534



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


[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-18 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D72751#1880120 , @labath wrote:

> I think we should just have DynamicLoaderStatic disqualify itself for wasm 
> files -- using it will never work there, so why should it pretend to support 
> them...


The triple clearly has an environment set of "wasm" so it should be easy to 
detect this in the DynamicLoaderStatic and stop it from saying it can handle 
it. The main issue then is do we have DynamicLoaderStatic say it can't handle 
anything if any environment is set, or just not for "wasm" (if OS and vendor 
are not set either).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


Re: [Lldb-commits] [PATCH] D74478: [lldb] Let TypeSystemClang::GetDisplayTypeName remove anonymous and inline namespaces.

2020-02-18 Thread Jim Ingham via lldb-commits
Yes, I don't think you have to solve this problem to make the suggested change. 
 

I think a lot of folks would appreciate the effort it would take to make names 
in backtraces more readable.  Sometimes, particularly when you use function 
objects and iterators in combination, the names are insanely long and pretty 
much impossible to read.  There's only so much we can tell from a mangled name 
- as opposed to having the full decl's, but I bet we could still get a pretty 
good compression from the tree-demangling and some heuristics.  So my main 
point was that we need to address shortening names in backtraces, but keeping 
them too long elsewhere isn't the right direction...

Jim


> On Feb 18, 2020, at 4:29 AM, Raphael Isemann via Phabricator 
>  wrote:
> 
> teemperor added a comment.
> 
> In D74478#1874746 , @jingham wrote:
> 
>> The only hesitation I have about this is if we are still printing this noise 
>> in demangled names, then the name of the type you see for a variable will be 
>> different from what you see when a method of that type ends up in a 
>> backtrace.  That might be confusing.  OTOH, the correct solution to that 
>> problem, IMO, is to remove the noise from backtraces, not keep it in the 
>> types...
> 
> 
> I'm not entirely sure how/if we can make the backtraces nicer as we only have 
> the function type (but not the specific function declaration with the name) 
> and mangled/demangled name for them. Removing the `anonymous namespace` from 
> the backtrace is doable with that, but inline namespaces and default template 
> arguments (which are part of the radar) aren't possible unless we start doing 
> much more work for the backtraces and figure out the actual FunctionDecls 
> behind each function.
> 
> FWIW, the current way we express backtraces is anyway not identical to what 
> we show in variables. Any typedefs and so on are lost in the mangled name, so 
> stepping into `std::string` member functions brings users to a backtrace with 
> in `std::__1::basic_string, 
> std::__1::allocator >::foo`. However printing the string shows them 
> `std::__1::string`.
> 
> 
> Repository:
>  rLLDB LLDB
> 
> CHANGES SINCE LAST ACTION
>  https://reviews.llvm.org/D74478/new/
> 
> https://reviews.llvm.org/D74478
> 
> 
> 

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


[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-18 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

In D72751#1880975 , @clayborg wrote:

> The triple clearly has an environment set of "wasm" so it should be easy to 
> detect this in the DynamicLoaderStatic and stop it from saying it can handle 
> it. The main issue then is do we have DynamicLoaderStatic say it can't handle 
> anything if any environment is set, or just not for "wasm" (if OS and vendor 
> are not set either).


"Wasm" is an "architecture" (and an object file format), not an environment, 
but yeah, I think it should just check for wasm specifically for now. If we see 
a pattern developing later, we can change that...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [lldb] 884a589 - [lldb/Plugin] Unconditionally initialize DynamicLoaderDarwinKernel

2020-02-18 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-18T10:32:06-08:00
New Revision: 884a58948b1a666910dcf1408d3d792fbd486012

URL: 
https://github.com/llvm/llvm-project/commit/884a58948b1a666910dcf1408d3d792fbd486012
DIFF: 
https://github.com/llvm/llvm-project/commit/884a58948b1a666910dcf1408d3d792fbd486012.diff

LOG: [lldb/Plugin] Unconditionally initialize DynamicLoaderDarwinKernel

Other plugins depend on DynamicLoaderDarwinKernel and which means we
cannot conditionally enable/build this plugin based on the target
platform. This means that it will be past of the list of plugins
initialized once that's autogenerated.

Added: 


Modified: 
lldb/source/API/SystemInitializerFull.cpp
lldb/tools/lldb-test/SystemInitializerTest.cpp

Removed: 




diff  --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index 4593bd3e0c43..21a00cb8c79e 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -98,11 +98,11 @@ LLDB_PLUGIN_DECLARE(ProcessFreeBSD)
 #if defined(__APPLE__)
 LLDB_PLUGIN_DECLARE(SymbolVendorMacOSX)
 LLDB_PLUGIN_DECLARE(ProcessMacOSXKernel)
-LLDB_PLUGIN_DECLARE(DynamicLoaderDarwinKernel)
 #endif
 LLDB_PLUGIN_DECLARE(StructuredDataDarwinLog)
 LLDB_PLUGIN_DECLARE(PlatformGDB)
 LLDB_PLUGIN_DECLARE(ProcessGDBRemote)
+LLDB_PLUGIN_DECLARE(DynamicLoaderDarwinKernel)
 LLDB_PLUGIN_DECLARE(DynamicLoaderHexagonDYLD)
 LLDB_PLUGIN_DECLARE(DynamicLoaderMacOSXDYLD)
 LLDB_PLUGIN_DECLARE(DynamicLoaderPosixDYLD)
@@ -231,7 +231,6 @@ llvm::Error SystemInitializerFull::Initialize() {
 #if defined(__APPLE__)
   LLDB_PLUGIN_INITIALIZE(SymbolVendorMacOSX);
   LLDB_PLUGIN_INITIALIZE(ProcessMacOSXKernel);
-  LLDB_PLUGIN_INITIALIZE(DynamicLoaderDarwinKernel);
 #endif
 
   // This plugin is valid on any host that talks to a Darwin remote. It
@@ -240,14 +239,15 @@ llvm::Error SystemInitializerFull::Initialize() {
 
   // Platform agnostic plugins
   LLDB_PLUGIN_INITIALIZE(PlatformGDB);
-
   LLDB_PLUGIN_INITIALIZE(ProcessGDBRemote);
+
+  LLDB_PLUGIN_INITIALIZE(DynamicLoaderDarwinKernel);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderHexagonDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderMacOSXDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderPosixDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderWasmDYLD); // Before DynamicLoaderStatic.
-  LLDB_PLUGIN_INITIALIZE(DynamicLoaderStatic);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderWindowsDYLD);
+  LLDB_PLUGIN_INITIALIZE(DynamicLoaderStatic);
 
   // Scan for any system or user LLDB plug-ins
   PluginManager::Initialize();
@@ -317,7 +317,6 @@ void SystemInitializerFull::Terminate() {
   LLDB_PLUGIN_TERMINATE(ObjCPlusPlusLanguage);
 
 #if defined(__APPLE__)
-  LLDB_PLUGIN_TERMINATE(DynamicLoaderDarwinKernel);
   LLDB_PLUGIN_TERMINATE(ProcessMacOSXKernel);
   LLDB_PLUGIN_TERMINATE(SymbolVendorMacOSX);
 #endif
@@ -331,12 +330,13 @@ void SystemInitializerFull::Terminate() {
   LLDB_PLUGIN_TERMINATE(ProcessGDBRemote);
   LLDB_PLUGIN_TERMINATE(StructuredDataDarwinLog);
 
+  LLDB_PLUGIN_TERMINATE(DynamicLoaderDarwinKernel);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderHexagonDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderMacOSXDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderPosixDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderWasmDYLD);
-  LLDB_PLUGIN_TERMINATE(DynamicLoaderStatic);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderWindowsDYLD);
+  LLDB_PLUGIN_TERMINATE(DynamicLoaderStatic);
 
   LLDB_PLUGIN_TERMINATE(PlatformFreeBSD);
   LLDB_PLUGIN_TERMINATE(PlatformLinux);

diff  --git a/lldb/tools/lldb-test/SystemInitializerTest.cpp 
b/lldb/tools/lldb-test/SystemInitializerTest.cpp
index bc5d119a30a1..1a3bf612674d 100644
--- a/lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ b/lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -84,11 +84,11 @@ LLDB_PLUGIN_DECLARE(ProcessFreeBSD)
 #if defined(__APPLE__)
 LLDB_PLUGIN_DECLARE(SymbolVendorMacOSX)
 LLDB_PLUGIN_DECLARE(ProcessMacOSXKernel)
-LLDB_PLUGIN_DECLARE(DynamicLoaderDarwinKernel)
 #endif
 LLDB_PLUGIN_DECLARE(StructuredDataDarwinLog)
 LLDB_PLUGIN_DECLARE(PlatformGDB)
 LLDB_PLUGIN_DECLARE(ProcessGDBRemote)
+LLDB_PLUGIN_DECLARE(DynamicLoaderDarwinKernel)
 LLDB_PLUGIN_DECLARE(DynamicLoaderHexagonDYLD)
 LLDB_PLUGIN_DECLARE(DynamicLoaderMacOSXDYLD)
 LLDB_PLUGIN_DECLARE(DynamicLoaderPosixDYLD)
@@ -206,7 +206,6 @@ llvm::Error SystemInitializerTest::Initialize() {
 #if defined(__APPLE__)
   LLDB_PLUGIN_INITIALIZE(SymbolVendorMacOSX);
   LLDB_PLUGIN_INITIALIZE(ProcessMacOSXKernel);
-  LLDB_PLUGIN_INITIALIZE(DynamicLoaderDarwinKernel);
 #endif
 
   // This plugin is valid on any host that talks to a Darwin remote. It
@@ -215,14 +214,15 @@ llvm::Error SystemInitializerTest::Initialize() {
 
   // Platform agnostic plugins
   LLDB_PLUGIN_INITIALIZE(PlatformGDB);
-
   LLDB_PLUGIN_INITIALIZE(ProcessGDBRemote);
+
+  LLDB_PLUGIN_INITIALIZE(DynamicLoaderDarwinKernel);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderHexagonDYLD);
   LLDB_P

[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-18 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

If we switch to auto registration of plug-in in the near future there are many 
things we need to watch out for and some notion of ordering needs to happen. A 
few examples:

- SymbolFileDWARFDebugMap and SymbolFileDWARF. Right now SymbolFileDWARF comes 
first and will claim a file before SymbolFileDWARFDebugMap. If 
SymbolFileDWARFDebugMap comes it will waste time iterating over all symbols in 
the symbol table, which causes the entire symbol table to be pulled in, and 
looks linearly for a symbol with type lldb::eSymbolTypeObjectFile, It will also 
claims it can parse the debug info just as well as SymbolFileDWARF, so it might 
end up getting used even though we have a dSYM file. So we need a way to avoid 
this. Right now ordering is used I believe. So the 
SymbolFileDWARFDebugMap::CalculateAbilities() might need to check if 
SymbolFileDWARF::CalculateAbilities() has all the abilities first, and just 
respond with no abilities in that case.
- SymbolFileSymtab and any other SymbolFile. SymbolFileSymtab will spend time 
going through the symbol table looking for symbols that describe any debug 
info. We want this to come last all the time and use this plug-in as a last 
resort.
- ObjectFile plug-ins can be ordered more efficiently for the current system 
(have ObjectFileMachO come first on Apple hosts, ObjectFileELF for non windows, 
ObjectFileCOFF for windows, etc). Not required, but would be nice.
- DynamicLoaderStatic vs any target that doesn't have OS, vendor or environment 
set.

, we might need to bolster the plug-in system a bit to be more like the 
SymbolFile plug-ins. For symbol file plug-ins we have each on calculate 
abilities and say


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [PATCH] D74727: Allow customized relative PYTHONHOME

2020-02-18 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 245206.
hhb marked 5 inline comments as done.
hhb added a comment.

Fix comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74727

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -279,12 +279,34 @@
   void InitializePythonHome() {
 #if defined(LLDB_PYTHON_HOME)
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+absolute_python_home = path.c_str();
+  }
+#if PY_MAJOR_VERSION >= 3
+  size_t size = 0;
+  return Py_DecodeLocale(absolute_python_home, &size);
+#else
+  return strdup(absolute_python_home);
+#endif
+}();
+if (g_python_home != nullptr) {
+  Py_SetPythonHome(g_python_home);
+}
 #else
 #if defined(__APPLE__) && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 7
 // For Darwin, the only Python version supported is the one shipped in the
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -59,7 +59,13 @@
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in 
LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
 add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION 2.8)
 
-option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." OFF)
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+  set(default_relocatable_python OFF)
+else()
+  set(default_relocatable_python ON)
+endif()
+
+option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." ${default_relocatable_python})
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install 
a copy of it" OFF)
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
 option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
@@ -141,9 +147,11 @@
 
 if (LLDB_ENABLE_PYTHON)
   include_directories(${PYTHON_INCLUDE_DIRS})
-  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND NOT 
LLDB_RELOCATABLE_PYTHON)
+  if (NOT LLDB_RELOCATABLE_PYTHON)
 get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY)
-file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
+set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
+  "Path to use as PYTHONHOME in lldb. If a relative path is specified, \
+  it will be resolved at runtime relative to liblldb directory.")
   endif()
 endif()
 


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -279,12 +279,34 @@
   void InitializePythonHome() {
 #if defined(LLDB_PYTHON_HOME)
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+absolute_python_home = path.c_str();
+  }
+#if PY_MAJOR_VERSION >= 3
+  size_t

[Lldb-commits] [PATCH] D74727: Allow customized relative PYTHONHOME

2020-02-18 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 245211.
hhb added a comment.

Fix comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74727

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -279,12 +279,34 @@
   void InitializePythonHome() {
 #if defined(LLDB_PYTHON_HOME)
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+absolute_python_home = path.c_str();
+  }
+#if PY_MAJOR_VERSION >= 3
+  size_t size = 0;
+  return Py_DecodeLocale(absolute_python_home, &size);
+#else
+  return strdup(absolute_python_home);
+#endif
+}();
+if (g_python_home != nullptr) {
+  Py_SetPythonHome(g_python_home);
+}
 #else
 #if defined(__APPLE__) && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 7
 // For Darwin, the only Python version supported is the one shipped in the
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -59,7 +59,13 @@
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in 
LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
 add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION 2.8)
 
-option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." OFF)
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+  set(default_relocatable_python OFF)
+else()
+  set(default_relocatable_python ON)
+endif()
+
+option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." ${default_relocatable_python})
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install 
a copy of it" OFF)
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
 option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
@@ -141,9 +147,11 @@
 
 if (LLDB_ENABLE_PYTHON)
   include_directories(${PYTHON_INCLUDE_DIRS})
-  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND NOT 
LLDB_RELOCATABLE_PYTHON)
+  if (NOT LLDB_RELOCATABLE_PYTHON)
 get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY)
-file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
+set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
+  "Path to use as PYTHONHOME in lldb. If a relative path is specified, \
+  it will be resolved at runtime relative to liblldb directory.")
   endif()
 endif()
 


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -279,12 +279,34 @@
   void InitializePythonHome() {
 #if defined(LLDB_PYTHON_HOME)
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+absolute_python_home = path.c_str();
+  }
+#if PY_MAJOR_VERSION >= 3
+  size_t size = 0;
+  return Py_DecodeLoc

[Lldb-commits] [PATCH] D74727: Allow customized relative PYTHONHOME

2020-02-18 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

> Can we maybe rename it to something like that?

LLDB_RELOCATABLE_PYTHON is misleading. I'd be happy to rename it. But that may 
break people who already set this flag.

Is there a standard procedure to do this? Maybe add the new one and remove the 
old one a year later? Or maybe fail when the old is set. So that at least 
people know how to fix?

> Or maybe even just a single LLDB_PYTHON_HOME variable, with the empty value 
> meaning we use the default python mechanism (PYTHONHOME env var, or the 
> baked-in python default)?

To do that, we have to make LLDB_PYTHON_HOME default to PYTHON_HOME for 
Windows. And if windows users want to make it "relocatable", they should set 
LLDB_PYTHON_HOME back to empty. That's also somehow weird...

> The other thing which bugs me is that the relative python path chosen here 
> will likely only be correct once lldb is installed. Will it be possible to 
> run lldb (and its test suite) configured in this way directly from the build 
> tree? I don't know if there's anything we can or should do about that, but 
> this situation seems less than ideal...

If someone uses relative python, that mean they should be responsible to put 
Python at the right place. No matter it is build tree or install tree. Or in 
other words, the install tree won't work by default either. People still need 
to put a symlink to python at the right place.




Comment at: lldb/cmake/modules/LLDBConfig.cmake:68
+
+option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." {default_relocatable_python})
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install 
a copy of it" OFF)

labath wrote:
> missing `$` in {default_relocatable_python}
Good catch. Thanks!



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp:298
+llvm::sys::path::append(path, lldb_python_home);
+llvm::sys::path::remove_dots(path, /* remove_dot_dots = */ true);
+absolute_python_home = path.c_str();

labath wrote:
> Is the `remove_dot_dots` really necessary? It can produce unexpected results 
> when `..`s back up over symlinks...
I was just trying to make the string shorter. It is not necessary. Removed.

But just curious what is the unexpected result? Say if I have a symlink 
"/src/python" -> "/usr/local/lib/python3.7", a "/src/python/../" should be 
resolved to /src, with or without remove_dot_dots?

Well I guess things get more interesting when liblldb is a symlink... That 
doesn't affect my use case though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74727



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


[Lldb-commits] [PATCH] D74780: [lldb/Plugin] Reject WASM and Hexagon in DynamicLoaderStatic

2020-02-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, clayborg, ted, paolosev.
Herald added subscribers: abidh, sunfish, aheejin.
Herald added a project: LLDB.

The WASM and Hexagon plugin check the ArchType rather than the OSType, so 
explicitly reject those in the DynamicLoaderStatic.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D74780

Files:
  lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp


Index: lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
===
--- lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
+++ lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
@@ -29,8 +29,19 @@
 const llvm::Triple &triple_ref =
 process->GetTarget().GetArchitecture().GetTriple();
 const llvm::Triple::OSType os_type = triple_ref.getOS();
-if ((os_type == llvm::Triple::UnknownOS))
-  create = true;
+const llvm::Triple::ArchType arch_type = triple_ref.getArch();
+if (os_type == llvm::Triple::UnknownOS) {
+  // The WASM and Hexagon plugin check the ArchType rather than the OSType,
+  // so explicitly reject those here.
+  switch(arch_type) {
+case llvm::Triple::hexagon:
+case llvm::Triple::wasm32:
+case llvm::Triple::wasm64:
+  break;
+default:
+  create = true;
+  }
+}
   }
 
   if (!create) {


Index: lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
===
--- lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
+++ lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
@@ -29,8 +29,19 @@
 const llvm::Triple &triple_ref =
 process->GetTarget().GetArchitecture().GetTriple();
 const llvm::Triple::OSType os_type = triple_ref.getOS();
-if ((os_type == llvm::Triple::UnknownOS))
-  create = true;
+const llvm::Triple::ArchType arch_type = triple_ref.getArch();
+if (os_type == llvm::Triple::UnknownOS) {
+  // The WASM and Hexagon plugin check the ArchType rather than the OSType,
+  // so explicitly reject those here.
+  switch(arch_type) {
+case llvm::Triple::hexagon:
+case llvm::Triple::wasm32:
+case llvm::Triple::wasm64:
+  break;
+default:
+  create = true;
+  }
+}
   }
 
   if (!create) {
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74727: Allow customized relative PYTHONHOME

2020-02-18 Thread Haibo Huang via Phabricator via lldb-commits
hhb marked an inline comment as done.
hhb added inline comments.



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp:298
+llvm::sys::path::append(path, lldb_python_home);
+llvm::sys::path::remove_dots(path, /* remove_dot_dots = */ true);
+absolute_python_home = path.c_str();

hhb wrote:
> labath wrote:
> > Is the `remove_dot_dots` really necessary? It can produce unexpected 
> > results when `..`s back up over symlinks...
> I was just trying to make the string shorter. It is not necessary. Removed.
> 
> But just curious what is the unexpected result? Say if I have a symlink 
> "/src/python" -> "/usr/local/lib/python3.7", a "/src/python/../" should be 
> resolved to /src, with or without remove_dot_dots?
> 
> Well I guess things get more interesting when liblldb is a symlink... That 
> doesn't affect my use case though.
Kind of understood after searching around. For me remove_dot_dots is the 
expected behavior. But yea let's remove it to reduce some confusion...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74727



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


[Lldb-commits] [PATCH] D72751: [LLDB] Add DynamicLoaderWasmDYLD plugin for WebAssembly debugging

2020-02-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

I went through the DYLD plugins and only the WASM and Hexagon plugin check the 
ArchType rather than the OSType, so I've created a patch to explicitly reject 
those in the DynamicLoaderStatic plugin: https://reviews.llvm.org/D74780


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72751



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


[Lldb-commits] [lldb] 2d146aa - [lldb/Plugin] Generate LLDB_PLUGIN_DECLARE with CMake

2020-02-18 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-18T11:29:56-08:00
New Revision: 2d146aa2a2cdef330877b511b54886823e71f92c

URL: 
https://github.com/llvm/llvm-project/commit/2d146aa2a2cdef330877b511b54886823e71f92c
DIFF: 
https://github.com/llvm/llvm-project/commit/2d146aa2a2cdef330877b511b54886823e71f92c.diff

LOG: [lldb/Plugin] Generate LLDB_PLUGIN_DECLARE with CMake

Generate the LLDB_PLUGIN_DECLARE macros with CMake and a def file. I'm
landing D73067 in pieces so I can bisect what exactly is breaking the
Windows bot.

Added: 
lldb/source/Plugins/Plugins.def.in

Modified: 
lldb/source/API/SystemInitializerFull.cpp
lldb/source/Plugins/CMakeLists.txt
lldb/tools/lldb-test/CMakeLists.txt
lldb/tools/lldb-test/SystemInitializerTest.cpp

Removed: 




diff  --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index 21a00cb8c79e..0613cd5a9e1f 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -24,91 +24,8 @@
 
 #include 
 
-LLDB_PLUGIN_DECLARE(ABIAArch64)
-LLDB_PLUGIN_DECLARE(ABIARM)
-LLDB_PLUGIN_DECLARE(ABIARC)
-LLDB_PLUGIN_DECLARE(ABIHexagon)
-LLDB_PLUGIN_DECLARE(ABIMips)
-LLDB_PLUGIN_DECLARE(ABIPowerPC)
-LLDB_PLUGIN_DECLARE(ABISystemZ)
-LLDB_PLUGIN_DECLARE(ABIX86)
-LLDB_PLUGIN_DECLARE(ObjectFileBreakpad)
-LLDB_PLUGIN_DECLARE(ObjectFileELF)
-LLDB_PLUGIN_DECLARE(ObjectFileJIT)
-LLDB_PLUGIN_DECLARE(ObjectFileMachO)
-LLDB_PLUGIN_DECLARE(ObjectFilePECOFF)
-LLDB_PLUGIN_DECLARE(ObjectFileWasm)
-LLDB_PLUGIN_DECLARE(ObjectContainerBSDArchive)
-LLDB_PLUGIN_DECLARE(ObjectContainerMachOArchive)
-LLDB_PLUGIN_DECLARE(ScriptInterpreterNone)
-#if LLDB_ENABLE_PYTHON
-LLDB_PLUGIN_DECLARE(OperatingSystemPython)
-LLDB_PLUGIN_DECLARE(ScriptInterpreterPython)
-#endif
-#if LLDB_ENABLE_LUA
-LLDB_PLUGIN_DECLARE(ScriptInterpreterLua)
-#endif
-LLDB_PLUGIN_DECLARE(PlatformFreeBSD)
-LLDB_PLUGIN_DECLARE(PlatformLinux)
-LLDB_PLUGIN_DECLARE(PlatformNetBSD)
-LLDB_PLUGIN_DECLARE(PlatformOpenBSD)
-LLDB_PLUGIN_DECLARE(PlatformWindows)
-LLDB_PLUGIN_DECLARE(PlatformAndroid)
-LLDB_PLUGIN_DECLARE(PlatformMacOSX)
-LLDB_PLUGIN_DECLARE(TypeSystemClang)
-LLDB_PLUGIN_DECLARE(ArchitectureArm)
-LLDB_PLUGIN_DECLARE(ArchitectureMips)
-LLDB_PLUGIN_DECLARE(ArchitecturePPC64)
-LLDB_PLUGIN_DECLARE(DisassemblerLLVMC)
-LLDB_PLUGIN_DECLARE(JITLoaderGDB)
-LLDB_PLUGIN_DECLARE(ProcessElfCore)
-LLDB_PLUGIN_DECLARE(ProcessMachCore)
-LLDB_PLUGIN_DECLARE(ProcessMinidump)
-LLDB_PLUGIN_DECLARE(MemoryHistoryASan)
-LLDB_PLUGIN_DECLARE(InstrumentationRuntimeASan)
-LLDB_PLUGIN_DECLARE(InstrumentationRuntimeTSan)
-LLDB_PLUGIN_DECLARE(InstrumentationRuntimeUBSan)
-LLDB_PLUGIN_DECLARE(InstrumentationRuntimeMainThreadChecker)
-LLDB_PLUGIN_DECLARE(SymbolVendorELF)
-LLDB_PLUGIN_DECLARE(SymbolFileBreakpad)
-LLDB_PLUGIN_DECLARE(SymbolFileDWARF)
-LLDB_PLUGIN_DECLARE(SymbolFilePDB)
-LLDB_PLUGIN_DECLARE(SymbolFileSymtab)
-LLDB_PLUGIN_DECLARE(SymbolVendorWasm)
-LLDB_PLUGIN_DECLARE(UnwindAssemblyInstEmulation)
-LLDB_PLUGIN_DECLARE(UnwindAssemblyX86)
-LLDB_PLUGIN_DECLARE(InstructionARM)
-LLDB_PLUGIN_DECLARE(InstructionARM64)
-LLDB_PLUGIN_DECLARE(InstructionMIPS)
-LLDB_PLUGIN_DECLARE(InstructionMIPS64)
-LLDB_PLUGIN_DECLARE(InstructionPPC64)
-LLDB_PLUGIN_DECLARE(CXXItaniumABI)
-LLDB_PLUGIN_DECLARE(AppleObjCRuntime)
-LLDB_PLUGIN_DECLARE(SystemRuntimeMacOSX)
-LLDB_PLUGIN_DECLARE(RenderScriptRuntime)
-LLDB_PLUGIN_DECLARE(CPlusPlusLanguage)
-LLDB_PLUGIN_DECLARE(ObjCLanguage)
-LLDB_PLUGIN_DECLARE(ObjCPlusPlusLanguage)
-#if defined(_WIN32)
-LLDB_PLUGIN_DECLARE(ProcessWindowsCommon)
-#endif
-#if defined(__FreeBSD__)
-LLDB_PLUGIN_DECLARE(ProcessFreeBSD)
-#endif
-#if defined(__APPLE__)
-LLDB_PLUGIN_DECLARE(SymbolVendorMacOSX)
-LLDB_PLUGIN_DECLARE(ProcessMacOSXKernel)
-#endif
-LLDB_PLUGIN_DECLARE(StructuredDataDarwinLog)
-LLDB_PLUGIN_DECLARE(PlatformGDB)
-LLDB_PLUGIN_DECLARE(ProcessGDBRemote)
-LLDB_PLUGIN_DECLARE(DynamicLoaderDarwinKernel)
-LLDB_PLUGIN_DECLARE(DynamicLoaderHexagonDYLD)
-LLDB_PLUGIN_DECLARE(DynamicLoaderMacOSXDYLD)
-LLDB_PLUGIN_DECLARE(DynamicLoaderPosixDYLD)
-LLDB_PLUGIN_DECLARE(DynamicLoaderStatic)
-LLDB_PLUGIN_DECLARE(DynamicLoaderWasmDYLD)
-LLDB_PLUGIN_DECLARE(DynamicLoaderWindowsDYLD)
+#define LLDB_PLUGIN(p) LLDB_PLUGIN_DECLARE(p)
+#include "Plugins/Plugins.def"
 
 using namespace lldb_private;
 

diff  --git a/lldb/source/Plugins/CMakeLists.txt 
b/lldb/source/Plugins/CMakeLists.txt
index 08817baec14c..24fb85811797 100644
--- a/lldb/source/Plugins/CMakeLists.txt
+++ b/lldb/source/Plugins/CMakeLists.txt
@@ -21,3 +21,25 @@ add_subdirectory(SystemRuntime)
 add_subdirectory(SymbolVendor)
 add_subdirectory(TypeSystem)
 add_subdirectory(UnwindAssembly)
+
+set(LLDB_STRIPPED_PLUGINS)
+get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS)
+
+set(LLDB_ENUM_PLUGINS "")
+
+foreach(p ${LLDB_ALL_PLUGINS})
+  # Strip lldbPlugin form the plugin name.
+  string(SUBSTRING ${p} 10 -1 pStripped)
+  if(${pS

[Lldb-commits] [PATCH] D74780: [lldb/Plugin] Reject WASM and Hexagon in DynamicLoaderStatic

2020-02-18 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

LGTM. Any way to test this somehow?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74780



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


[Lldb-commits] [PATCH] D74780: [lldb/Plugin] Reject WASM and Hexagon in DynamicLoaderStatic

2020-02-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Sorting the plugins so the static loader is initialized before the WASM loader 
should exercise this code path.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74780



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


[Lldb-commits] [PATCH] D74780: [lldb/Plugin] Reject WASM and Hexagon in DynamicLoaderStatic

2020-02-18 Thread Paolo Severini via Phabricator via lldb-commits
paolosev accepted this revision.
paolosev added a comment.
This revision is now accepted and ready to land.

In D74780#1881297 , @JDevlieghere 
wrote:

> Sorting the plugins so the static loader is initialized before the WASM 
> loader should exercise this code path.


Yes, test //functionalities/gdb_remote_client/TestWasm.py// fails when the 
order of plugins is sorted.

LGTM. Could you also sort the initialization of DynamicLoaderStatic and 
DynamicLoaderWasmDYLD in lldb\tools\lldb-test\SystemInitializerTest.cpp and 
lldb\source\API\SystemInitializerFull.cpp?


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74780



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


[Lldb-commits] [lldb] ebf9a99 - [lldb/Plugin] Reject WASM and Hexagon in DynamicLoaderStatic

2020-02-18 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-18T13:29:34-08:00
New Revision: ebf9a99bbdcd88f15f16480f4d9b8f39d280f105

URL: 
https://github.com/llvm/llvm-project/commit/ebf9a99bbdcd88f15f16480f4d9b8f39d280f105
DIFF: 
https://github.com/llvm/llvm-project/commit/ebf9a99bbdcd88f15f16480f4d9b8f39d280f105.diff

LOG: [lldb/Plugin] Reject WASM and Hexagon in DynamicLoaderStatic

The WASM and Hexagon plugin check the ArchType rather than the OSType,
so explicitly reject those in the DynamicLoaderStatic.

Differential revision: https://reviews.llvm.org/D74780

Added: 


Modified: 
lldb/source/API/SystemInitializerFull.cpp
lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
lldb/tools/lldb-test/SystemInitializerTest.cpp

Removed: 




diff  --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index 0613cd5a9e1f..dfada58700c3 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -162,9 +162,9 @@ llvm::Error SystemInitializerFull::Initialize() {
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderHexagonDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderMacOSXDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderPosixDYLD);
-  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWasmDYLD); // Before DynamicLoaderStatic.
-  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWindowsDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderStatic);
+  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWasmDYLD);
+  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWindowsDYLD);
 
   // Scan for any system or user LLDB plug-ins
   PluginManager::Initialize();
@@ -251,9 +251,9 @@ void SystemInitializerFull::Terminate() {
   LLDB_PLUGIN_TERMINATE(DynamicLoaderHexagonDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderMacOSXDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderPosixDYLD);
+  LLDB_PLUGIN_TERMINATE(DynamicLoaderStatic);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderWasmDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderWindowsDYLD);
-  LLDB_PLUGIN_TERMINATE(DynamicLoaderStatic);
 
   LLDB_PLUGIN_TERMINATE(PlatformFreeBSD);
   LLDB_PLUGIN_TERMINATE(PlatformLinux);

diff  --git a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp 
b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
index 13aad5f4ccb6..48762fe6e0c3 100644
--- a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
@@ -29,8 +29,19 @@ DynamicLoader *DynamicLoaderStatic::CreateInstance(Process 
*process,
 const llvm::Triple &triple_ref =
 process->GetTarget().GetArchitecture().GetTriple();
 const llvm::Triple::OSType os_type = triple_ref.getOS();
-if ((os_type == llvm::Triple::UnknownOS))
-  create = true;
+const llvm::Triple::ArchType arch_type = triple_ref.getArch();
+if (os_type == llvm::Triple::UnknownOS) {
+  // The WASM and Hexagon plugin check the ArchType rather than the OSType,
+  // so explicitly reject those here.
+  switch(arch_type) {
+case llvm::Triple::hexagon:
+case llvm::Triple::wasm32:
+case llvm::Triple::wasm64:
+  break;
+default:
+  create = true;
+  }
+}
   }
 
   if (!create) {

diff  --git a/lldb/tools/lldb-test/SystemInitializerTest.cpp 
b/lldb/tools/lldb-test/SystemInitializerTest.cpp
index 020533554602..eceee50b5a4f 100644
--- a/lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ b/lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -144,9 +144,9 @@ llvm::Error SystemInitializerTest::Initialize() {
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderHexagonDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderMacOSXDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderPosixDYLD);
-  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWasmDYLD); // Before DynamicLoaderStatic.
-  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWindowsDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderStatic);
+  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWasmDYLD);
+  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWindowsDYLD);
 
   // Scan for any system or user LLDB plug-ins
   PluginManager::Initialize();
@@ -233,9 +233,9 @@ void SystemInitializerTest::Terminate() {
   LLDB_PLUGIN_TERMINATE(DynamicLoaderHexagonDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderMacOSXDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderPosixDYLD);
+  LLDB_PLUGIN_TERMINATE(DynamicLoaderStatic);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderWasmDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderWindowsDYLD);
-  LLDB_PLUGIN_TERMINATE(DynamicLoaderStatic);
 
   LLDB_PLUGIN_TERMINATE(PlatformFreeBSD);
   LLDB_PLUGIN_TERMINATE(PlatformLinux);



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


[Lldb-commits] [lldb] 0159c21 - [TestGlobalVariables] `target var` without a process doesn't work on arm64e.

2020-02-18 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2020-02-18T13:30:51-08:00
New Revision: 0159c21119ed5694c2804ec439e336b5b7e136ec

URL: 
https://github.com/llvm/llvm-project/commit/0159c21119ed5694c2804ec439e336b5b7e136ec
DIFF: 
https://github.com/llvm/llvm-project/commit/0159c21119ed5694c2804ec439e336b5b7e136ec.diff

LOG: [TestGlobalVariables] `target var` without a process doesn't work on 
arm64e.

lldb needs to know about chains of authenticated relocations.



Added: 


Modified: 
lldb/test/API/lang/c/global_variables/TestGlobalVariables.py

Removed: 




diff  --git a/lldb/test/API/lang/c/global_variables/TestGlobalVariables.py 
b/lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
index 04b874942acb..7f13bf0036ab 100644
--- a/lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
+++ b/lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
@@ -21,6 +21,7 @@ def setUp(self):
 self.shlib_names = ["a"]
 
 @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24764")
+@expectedFailureAll(archs=["arm64e"]) # 
 def test_without_process(self):
 """Test that static initialized variables can be inspected without
 process."""



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


[Lldb-commits] [lldb] 3f5e050 - [TestGlobalVariables] Remove a reference to a stale rdar.

2020-02-18 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2020-02-18T13:31:14-08:00
New Revision: 3f5e0501b5e28602320df37e740445a7f93bc24f

URL: 
https://github.com/llvm/llvm-project/commit/3f5e0501b5e28602320df37e740445a7f93bc24f
DIFF: 
https://github.com/llvm/llvm-project/commit/3f5e0501b5e28602320df37e740445a7f93bc24f.diff

LOG: [TestGlobalVariables] Remove a reference to a stale rdar.

The bug has been fixed and the rdar is closed. No need to
clutter the test.

Added: 


Modified: 
lldb/test/API/lang/c/global_variables/TestGlobalVariables.py

Removed: 




diff  --git a/lldb/test/API/lang/c/global_variables/TestGlobalVariables.py 
b/lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
index 7f13bf0036ab..c9160fd38549 100644
--- a/lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
+++ b/lldb/test/API/lang/c/global_variables/TestGlobalVariables.py
@@ -108,10 +108,6 @@ def test_c_global_variables(self):
 'g_marked_spot.x',
 '20'])
 
-# rdar://problem/9747668
-# runCmd: target variable g_marked_spot.y
-# output: (int) g_marked_spot.y = 
 self.expect(
 "target variable g_marked_spot.y",
 VARIABLES_DISPLAYED_CORRECTLY,



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


[Lldb-commits] [PATCH] D74780: [lldb/Plugin] Reject WASM and Hexagon in DynamicLoaderStatic

2020-02-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGebf9a99bbdcd: [lldb/Plugin] Reject WASM and Hexagon in 
DynamicLoaderStatic (authored by JDevlieghere).

Changed prior to commit:
  https://reviews.llvm.org/D74780?vs=245212&id=245252#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74780

Files:
  lldb/source/API/SystemInitializerFull.cpp
  lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
  lldb/tools/lldb-test/SystemInitializerTest.cpp


Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -144,9 +144,9 @@
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderHexagonDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderMacOSXDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderPosixDYLD);
-  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWasmDYLD); // Before DynamicLoaderStatic.
-  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWindowsDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderStatic);
+  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWasmDYLD);
+  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWindowsDYLD);
 
   // Scan for any system or user LLDB plug-ins
   PluginManager::Initialize();
@@ -233,9 +233,9 @@
   LLDB_PLUGIN_TERMINATE(DynamicLoaderHexagonDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderMacOSXDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderPosixDYLD);
+  LLDB_PLUGIN_TERMINATE(DynamicLoaderStatic);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderWasmDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderWindowsDYLD);
-  LLDB_PLUGIN_TERMINATE(DynamicLoaderStatic);
 
   LLDB_PLUGIN_TERMINATE(PlatformFreeBSD);
   LLDB_PLUGIN_TERMINATE(PlatformLinux);
Index: lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
===
--- lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
+++ lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp
@@ -29,8 +29,19 @@
 const llvm::Triple &triple_ref =
 process->GetTarget().GetArchitecture().GetTriple();
 const llvm::Triple::OSType os_type = triple_ref.getOS();
-if ((os_type == llvm::Triple::UnknownOS))
-  create = true;
+const llvm::Triple::ArchType arch_type = triple_ref.getArch();
+if (os_type == llvm::Triple::UnknownOS) {
+  // The WASM and Hexagon plugin check the ArchType rather than the OSType,
+  // so explicitly reject those here.
+  switch(arch_type) {
+case llvm::Triple::hexagon:
+case llvm::Triple::wasm32:
+case llvm::Triple::wasm64:
+  break;
+default:
+  create = true;
+  }
+}
   }
 
   if (!create) {
Index: lldb/source/API/SystemInitializerFull.cpp
===
--- lldb/source/API/SystemInitializerFull.cpp
+++ lldb/source/API/SystemInitializerFull.cpp
@@ -162,9 +162,9 @@
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderHexagonDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderMacOSXDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderPosixDYLD);
-  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWasmDYLD); // Before DynamicLoaderStatic.
-  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWindowsDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderStatic);
+  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWasmDYLD);
+  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWindowsDYLD);
 
   // Scan for any system or user LLDB plug-ins
   PluginManager::Initialize();
@@ -251,9 +251,9 @@
   LLDB_PLUGIN_TERMINATE(DynamicLoaderHexagonDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderMacOSXDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderPosixDYLD);
+  LLDB_PLUGIN_TERMINATE(DynamicLoaderStatic);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderWasmDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderWindowsDYLD);
-  LLDB_PLUGIN_TERMINATE(DynamicLoaderStatic);
 
   LLDB_PLUGIN_TERMINATE(PlatformFreeBSD);
   LLDB_PLUGIN_TERMINATE(PlatformLinux);


Index: lldb/tools/lldb-test/SystemInitializerTest.cpp
===
--- lldb/tools/lldb-test/SystemInitializerTest.cpp
+++ lldb/tools/lldb-test/SystemInitializerTest.cpp
@@ -144,9 +144,9 @@
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderHexagonDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderMacOSXDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderPosixDYLD);
-  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWasmDYLD); // Before DynamicLoaderStatic.
-  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWindowsDYLD);
   LLDB_PLUGIN_INITIALIZE(DynamicLoaderStatic);
+  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWasmDYLD);
+  LLDB_PLUGIN_INITIALIZE(DynamicLoaderWindowsDYLD);
 
   // Scan for any system or user LLDB plug-ins
   PluginManager::Initialize();
@@ -233,9 +233,9 @@
   LLDB_PLUGIN_TERMINATE(DynamicLoaderHexagonDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderMacOSXDYLD);
   LLDB_PLUGIN_TERMINATE(DynamicLoaderPosixDYLD);
+  LLDB_PLUGIN_TERMINATE(DynamicLoad

[Lldb-commits] [lldb] 2560a93 - [TestTargetCommand] `target var` without a process doesn't work on arm64e.

2020-02-18 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2020-02-18T13:38:27-08:00
New Revision: 2560a93b706245b442ac5bf208c48db4912de134

URL: 
https://github.com/llvm/llvm-project/commit/2560a93b706245b442ac5bf208c48db4912de134
DIFF: 
https://github.com/llvm/llvm-project/commit/2560a93b706245b442ac5bf208c48db4912de134.diff

LOG: [TestTargetCommand] `target var` without a process doesn't work on arm64e.

lldb needs to know about chains of authenticated relocations.



Added: 


Modified: 
lldb/test/API/commands/target/basic/TestTargetCommand.py

Removed: 




diff  --git a/lldb/test/API/commands/target/basic/TestTargetCommand.py 
b/lldb/test/API/commands/target/basic/TestTargetCommand.py
index 95df78eef12a..047b1073a961 100644
--- a/lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ b/lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -44,6 +44,7 @@ def test_target_command(self):
 self.buildAll()
 self.do_target_command()
 
+@expectedFailureAll(archs=['arm64e']) # 
 def test_target_variable_command(self):
 """Test 'target variable' command before and after starting the 
inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}
@@ -52,6 +53,7 @@ def test_target_variable_command(self):
 
 self.do_target_variable_command('globals')
 
+@expectedFailureAll(archs=['arm64e']) # 
 def test_target_variable_command_no_fail(self):
 """Test 'target variable' command before and after starting the 
inferior."""
 d = {'C_SOURCES': 'globals.c', 'EXE': self.getBuildArtifact('globals')}



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


[Lldb-commits] [lldb] 42cab98 - [TestTargetCommand] Remove another reference to a stale rdar.

2020-02-18 Thread Davide Italiano via lldb-commits

Author: Davide Italiano
Date: 2020-02-18T13:39:37-08:00
New Revision: 42cab985fd95ba4f3f290e7bb26b93805edb447d

URL: 
https://github.com/llvm/llvm-project/commit/42cab985fd95ba4f3f290e7bb26b93805edb447d
DIFF: 
https://github.com/llvm/llvm-project/commit/42cab985fd95ba4f3f290e7bb26b93805edb447d.diff

LOG: [TestTargetCommand] Remove another reference to a stale rdar.

The test passes, and the rdar is closed.

Added: 


Modified: 
lldb/test/API/commands/target/basic/TestTargetCommand.py

Removed: 




diff  --git a/lldb/test/API/commands/target/basic/TestTargetCommand.py 
b/lldb/test/API/commands/target/basic/TestTargetCommand.py
index 047b1073a961..2a5978c9844b 100644
--- a/lldb/test/API/commands/target/basic/TestTargetCommand.py
+++ b/lldb/test/API/commands/target/basic/TestTargetCommand.py
@@ -179,8 +179,6 @@ def do_target_variable_command(self, exe_name):
 
 self.runCmd("c")
 
-# rdar://problem/9763907
-# 'target variable' command fails if the target program has been run
 self.expect(
 "target variable my_global_str",
 VARIABLES_DISPLAYED_CORRECTLY,



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


[Lldb-commits] [PATCH] D74798: [lldb-vscode] Use libOption with tablegen to parse command line options.

2020-02-18 Thread Ivan Hernandez via Phabricator via lldb-commits
ivanhernandez13 created this revision.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.

This change will bring lldb-vscode in line with how several other llvm tools 
process command line arguments.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74798

Files:
  lldb/tools/lldb-vscode/CMakeLists.txt
  lldb/tools/lldb-vscode/Opts.td
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -41,8 +41,12 @@
 #include 
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/Option/Arg.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/Option.h"
 #include "llvm/Support/Errno.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/raw_ostream.h"
 
 #include "JSONUtils.h"
@@ -64,6 +68,34 @@
 using namespace lldb_vscode;
 
 namespace {
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, VALUES)  \
+  OPT_##ID,
+#include "Opts.inc"
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE) const char *const NAME[] = VALUE;
+#include "Opts.inc"
+#undef PREFIX
+
+static const llvm::opt::OptTable::Info InfoTable[] = {
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, VALUES)  \
+{  \
+  PREFIX,  NAME,  HELPTEXT,\
+  METAVAR, OPT_##ID,  llvm::opt::Option::KIND##Class,  \
+  PARAM,   FLAGS, OPT_##GROUP, \
+  OPT_##ALIAS, ALIASARGS, VALUES},
+#include "Opts.inc"
+#undef OPTION
+};
+class LLDBVSCodeOptTable : public llvm::opt::OptTable {
+public:
+  LLDBVSCodeOptTable() : OptTable(InfoTable, true) {}
+};
 
 typedef void (*RequestCallback)(const llvm::json::Object &command);
 
@@ -2719,31 +2751,70 @@
 
 } // anonymous namespace
 
+static void printHelp(LLDBVSCodeOptTable &table, llvm::StringRef tool_name) {
+  std::string usage_str = tool_name.str() + "options";
+  table.PrintHelp(llvm::outs(), usage_str.c_str(), "LLDB VSCode", false);
+
+  std::string examples = R"___(
+EXAMPLES:
+  The debug adapter can be started in two modes.
+
+  Running lldb-vscode without any arguments will start communicating with the
+  parent over stdio. Passing a port number causes lldb-vscode to start listening
+  for connections on that port.
+
+lldb-vscode -p 
+
+  Passing --wait-for-debugger will pause the process at startup and wait for a
+  debugger to attach to the process.
+
+lldb-vscode -g
+  )___";
+  llvm::outs() << examples;
+}
+
 int main(int argc, char *argv[]) {
 
   // Initialize LLDB first before we do anything.
   lldb::SBDebugger::Initialize();
 
-  if (argc == 2) {
-const char *arg = argv[1];
+  int portno = -1;
+
+  LLDBVSCodeOptTable T;
+  unsigned MAI, MAC;
+  llvm::ArrayRef ArgsArr = llvm::makeArrayRef(argv + 1, argc);
+  llvm::opt::InputArgList input_args = T.ParseArgs(ArgsArr, MAI, MAC);
+
+  if (input_args.hasArg(OPT_help)) {
+printHelp(T, llvm::sys::path::filename(argv[0]));
+return 0;
+  }
+
+  if (auto *arg = input_args.getLastArg(OPT_port)) {
+auto optarg = arg->getValue();
+char *remainder;
+portno = strtol(optarg, &remainder, 0);
+if (remainder == optarg || *remainder != '\0') {
+  fprintf(stderr, "'%s' is not a valid port number.\n", optarg);
+  exit(1);
+}
+  }
+
 #if !defined(_WIN32)
-if (strcmp(arg, "-g") == 0) {
-  printf("Paused waiting for debugger to attach (pid = %i)...\n", getpid());
-  pause();
-} else {
-#else
-{
+  if (input_args.hasArg(OPT_wait_for_debugger)) {
+printf("Paused waiting for debugger to attach (pid = %i)...\n", getpid());
+pause();
+  }
 #endif
-  int portno = atoi(arg);
-  printf("Listening on port %i...\n", portno);
-  SOCKET socket_fd = AcceptConnection(portno);
-  if (socket_fd >= 0) {
-g_vsc.input.descriptor = StreamDescriptor::from_socket(socket_fd, true);
-g_vsc.output.descriptor =
-StreamDescriptor::from_socket(socket_fd, false);
-  } else {
-exit(1);
-  }
+  if (portno != -1) {
+printf("Listening on port %i...\n", portno);
+SOCKET socket_fd = AcceptConnection(portno);
+if (socket_fd >= 0) {
+  g_vsc.input.descriptor = StreamDescriptor::from_socket(socket_fd, true);
+  g_vsc.output.descriptor =
+  StreamDescriptor::from_socket(socket_fd, false);
+} else {
+  exit(1);
 }
   } else {
 g_vsc.input.descriptor = StreamDescriptor::from_file(fileno(stdin), false);
Index: lldb/tools/lldb-v

[Lldb-commits] [PATCH] D74798: [lldb-vscode] Use libOption with tablegen to parse command line options.

2020-02-18 Thread Ivan Hernandez via Phabricator via lldb-commits
ivanhernandez13 added a comment.

Assuming this looks good, can I get some pointers on how and where I should add 
a test for this?

I based this change on the one for the LLDB driver 
(https://reviews.llvm.org/D54692) which added 
lldb/trunk/lit/Driver/TestCommands.test. Should I look into adding something 
similar or should I be using 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
and adding something in lldb/test/API/tools/lldb-vscode?

This is what the output for help looks like:

  ~/llvm-project ❯❯❯ build/Debug/bin/lldb-vscode --help 

  [INSERT]
  OVERVIEW: LLDB VSCode
  
  USAGE: lldb-vscodeoptions
  
  OPTIONS:
-g  Alias for --wait-for-debugger
--help  Prints out the usage information for the LLDB debug 
adapter tool.
-h  Alias for --help
--portWhat port to listen on.
-p   Alias for --port
--wait-for-debugger Pause the program at startup.
  
  EXAMPLES:
The debug adapter can be started in two modes.
  
Running lldb-vscode without any arguments will start communicating with the
parent over stdio. Passing a port number causes lldb-vscode to start 
listening
for connections on that port.
  
  lldb-vscode -p 
  
Passing --wait-for-debugger will pause the process at startup and wait for a
debugger to attach to the process.
  
  lldb-vscode -w
%


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74798



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


[Lldb-commits] [PATCH] D74798: [lldb-vscode] Use libOption with tablegen to parse command line options.

2020-02-18 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Looks good. I would add a .test file like the command line driver to cover this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74798



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


[Lldb-commits] [lldb] 7b76767 - [lldb/Core] Remove blatant code duplication by using a template (NFC)

2020-02-18 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-18T17:19:47-08:00
New Revision: 7b76767dbc4b1894c2c7ff397875cb2285e70446

URL: 
https://github.com/llvm/llvm-project/commit/7b76767dbc4b1894c2c7ff397875cb2285e70446
DIFF: 
https://github.com/llvm/llvm-project/commit/7b76767dbc4b1894c2c7ff397875cb2285e70446.diff

LOG: [lldb/Core] Remove blatant code duplication by using a template (NFC)

Remove a bunch of duplicate code by using a templated base class.

Added: 


Modified: 
lldb/source/Core/PluginManager.cpp

Removed: 




diff  --git a/lldb/source/Core/PluginManager.cpp 
b/lldb/source/Core/PluginManager.cpp
index 94dc44ee2860..556febcbfda9 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -197,16 +197,25 @@ void PluginManager::Terminate() {
   plugin_map.clear();
 }
 
-#pragma mark ABI
-
-struct ABIInstance {
-  ABIInstance() : name(), description(), create_callback(nullptr) {}
+template  struct PluginInstance {
+  PluginInstance() = default;
+  PluginInstance(ConstString name, std::string description,
+ Callback create_callback = nullptr,
+ DebuggerInitializeCallback debugger_init_callback = nullptr)
+  : name(name), description(std::move(description)),
+create_callback(create_callback),
+debugger_init_callback(debugger_init_callback) {}
 
   ConstString name;
   std::string description;
-  ABICreateInstance create_callback;
+  Callback create_callback;
+  DebuggerInitializeCallback debugger_init_callback;
 };
 
+#pragma mark ABI
+
+typedef PluginInstance ABIInstance;
+
 typedef std::vector ABIInstances;
 
 static std::recursive_mutex &GetABIInstancesMutex() {
@@ -219,8 +228,7 @@ static ABIInstances &GetABIInstances() {
   return g_instances;
 }
 
-bool PluginManager::RegisterPlugin(ConstString name,
-   const char *description,
+bool PluginManager::RegisterPlugin(ConstString name, const char *description,
ABICreateInstance create_callback) {
   if (create_callback) {
 ABIInstance instance;
@@ -277,17 +285,13 @@ 
PluginManager::GetABICreateCallbackForPluginName(ConstString name) {
 
 #pragma mark Architecture
 
-struct ArchitectureInstance {
-  ConstString name;
-  std::string description;
-  PluginManager::ArchitectureCreateInstance create_callback;
-};
-
+typedef PluginInstance
+ArchitectureInstance;
 typedef std::vector ArchitectureInstances;
 
 static std::mutex &GetArchitectureMutex() {
-static std::mutex g_architecture_mutex;
-return g_architecture_mutex;
+  static std::mutex g_architecture_mutex;
+  return g_architecture_mutex;
 }
 
 static ArchitectureInstances &GetArchitectureInstances() {
@@ -329,13 +333,7 @@ PluginManager::CreateArchitectureInstance(const ArchSpec 
&arch) {
 
 #pragma mark Disassembler
 
-struct DisassemblerInstance {
-  DisassemblerInstance() : name(), description(), create_callback(nullptr) {}
-
-  ConstString name;
-  std::string description;
-  DisassemblerCreateInstance create_callback;
-};
+typedef PluginInstance DisassemblerInstance;
 
 typedef std::vector DisassemblerInstances;
 
@@ -349,8 +347,7 @@ static DisassemblerInstances &GetDisassemblerInstances() {
   return g_instances;
 }
 
-bool PluginManager::RegisterPlugin(ConstString name,
-   const char *description,
+bool PluginManager::RegisterPlugin(ConstString name, const char *description,
DisassemblerCreateInstance create_callback) 
{
   if (create_callback) {
 DisassemblerInstance instance;
@@ -393,8 +390,7 @@ 
PluginManager::GetDisassemblerCreateCallbackAtIndex(uint32_t idx) {
 }
 
 DisassemblerCreateInstance
-PluginManager::GetDisassemblerCreateCallbackForPluginName(
-ConstString name) {
+PluginManager::GetDisassemblerCreateCallbackForPluginName(ConstString name) {
   if (name) {
 std::lock_guard guard(GetDisassemblerMutex());
 DisassemblerInstances &instances = GetDisassemblerInstances();
@@ -410,16 +406,7 @@ PluginManager::GetDisassemblerCreateCallbackForPluginName(
 
 #pragma mark DynamicLoader
 
-struct DynamicLoaderInstance {
-  DynamicLoaderInstance()
-  : name(), description(), create_callback(nullptr),
-debugger_init_callback(nullptr) {}
-
-  ConstString name;
-  std::string description;
-  DynamicLoaderCreateInstance create_callback;
-  DebuggerInitializeCallback debugger_init_callback;
-};
+typedef PluginInstance DynamicLoaderInstance;
 
 typedef std::vector DynamicLoaderInstances;
 
@@ -478,8 +465,7 @@ 
PluginManager::GetDynamicLoaderCreateCallbackAtIndex(uint32_t idx) {
 }
 
 DynamicLoaderCreateInstance
-PluginManager::GetDynamicLoaderCreateCallbackForPluginName(
-ConstString name) {
+PluginManager::GetDynamicLoaderCreateCallbackForPluginName(ConstString name) {
   if (name) {
 std::lock_guard guard(GetDynamicLoaderMutex());
 DynamicLoader

[Lldb-commits] [lldb] bad1389 - [lldb/Core] Remove dead Get*PluginCreateCallbackForPluginName (NFC)

2020-02-18 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-18T17:36:26-08:00
New Revision: bad1389f1252d1b77c5e31f0dadee92eb38d23a1

URL: 
https://github.com/llvm/llvm-project/commit/bad1389f1252d1b77c5e31f0dadee92eb38d23a1
DIFF: 
https://github.com/llvm/llvm-project/commit/bad1389f1252d1b77c5e31f0dadee92eb38d23a1.diff

LOG: [lldb/Core] Remove dead Get*PluginCreateCallbackForPluginName (NFC)

The plugin manager had dedicated Get*PluginCreateCallbackForPluginName
methods for each type of plugin, and only a small subset of those were
used. This removes the dead duplicated code.

Added: 


Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/source/Core/PluginManager.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index 259f7162d896..90db9cee06ac 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -61,8 +61,6 @@ class PluginManager {
 
   static ABICreateInstance GetABICreateCallbackAtIndex(uint32_t idx);
 
-  static ABICreateInstance GetABICreateCallbackForPluginName(ConstString name);
-
   // Architecture
   using ArchitectureCreateInstance =
   std::unique_ptr (*)(const ArchSpec &);
@@ -112,9 +110,6 @@ class PluginManager {
   static JITLoaderCreateInstance
   GetJITLoaderCreateCallbackAtIndex(uint32_t idx);
 
-  static JITLoaderCreateInstance
-  GetJITLoaderCreateCallbackForPluginName(ConstString name);
-
   // EmulateInstruction
   static bool RegisterPlugin(ConstString name, const char *description,
  EmulateInstructionCreateInstance create_callback);
@@ -149,9 +144,6 @@ class PluginManager {
 
   static LanguageCreateInstance GetLanguageCreateCallbackAtIndex(uint32_t idx);
 
-  static LanguageCreateInstance
-  GetLanguageCreateCallbackForPluginName(ConstString name);
-
   // LanguageRuntime
   static bool RegisterPlugin(
   ConstString name, const char *description,
@@ -170,9 +162,6 @@ class PluginManager {
   static LanguageRuntimeGetExceptionPrecondition
   GetLanguageRuntimeGetExceptionPreconditionAtIndex(uint32_t idx);
 
-  static LanguageRuntimeCreateInstance
-  GetLanguageRuntimeCreateCallbackForPluginName(ConstString name);
-
   // SystemRuntime
   static bool RegisterPlugin(ConstString name, const char *description,
  SystemRuntimeCreateInstance create_callback);
@@ -182,9 +171,6 @@ class PluginManager {
   static SystemRuntimeCreateInstance
   GetSystemRuntimeCreateCallbackAtIndex(uint32_t idx);
 
-  static SystemRuntimeCreateInstance
-  GetSystemRuntimeCreateCallbackForPluginName(ConstString name);
-
   // ObjectFile
   static bool
   RegisterPlugin(ConstString name, const char *description,
@@ -204,9 +190,6 @@ class PluginManager {
   static ObjectFileGetModuleSpecifications
   GetObjectFileGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
 
-  static ObjectFileCreateInstance
-  GetObjectFileCreateCallbackForPluginName(ConstString name);
-
   static ObjectFileCreateMemoryInstance
   GetObjectFileCreateMemoryCallbackForPluginName(ConstString name);
 
@@ -224,9 +207,6 @@ class PluginManager {
   static ObjectContainerCreateInstance
   GetObjectContainerCreateCallbackAtIndex(uint32_t idx);
 
-  static ObjectContainerCreateInstance
-  GetObjectContainerCreateCallbackForPluginName(ConstString name);
-
   static ObjectFileGetModuleSpecifications
   GetObjectContainerGetModuleSpecificationsCallbackAtIndex(uint32_t idx);
 
@@ -326,9 +306,6 @@ class PluginManager {
   static StructuredDataPluginCreateInstance
   GetStructuredDataPluginCreateCallbackAtIndex(uint32_t idx);
 
-  static StructuredDataPluginCreateInstance
-  GetStructuredDataPluginCreateCallbackForPluginName(ConstString name);
-
   static StructuredDataFilterLaunchInfo
   GetStructuredDataFilterCallbackAtIndex(uint32_t idx,
  bool &iteration_complete);
@@ -344,9 +321,6 @@ class PluginManager {
   static SymbolFileCreateInstance
   GetSymbolFileCreateCallbackAtIndex(uint32_t idx);
 
-  static SymbolFileCreateInstance
-  GetSymbolFileCreateCallbackForPluginName(ConstString name);
-
   // SymbolVendor
   static bool RegisterPlugin(ConstString name, const char *description,
  SymbolVendorCreateInstance create_callback);
@@ -356,9 +330,6 @@ class PluginManager {
   static SymbolVendorCreateInstance
   GetSymbolVendorCreateCallbackAtIndex(uint32_t idx);
 
-  static SymbolVendorCreateInstance
-  GetSymbolVendorCreateCallbackForPluginName(ConstString name);
-
   // UnwindAssembly
   static bool RegisterPlugin(ConstString name, const char *description,
  UnwindAssemblyCreateInstance create_callback);
@@ -368,9 +339,6 @@ class PluginManager {
   static UnwindAssemblyCreateInstance
   GetUnwindAssemblyCreateCallbackAtIndex(uint32_t idx);
 
-  static UnwindAssemblyCreateInstance
-  GetUnwindAssembly

[Lldb-commits] [lldb] 80c3ea4 - Re-land "[lldb/CMake] Auto-generate the Initialize and Terminate calls for plugin"

2020-02-18 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-18T19:16:07-08:00
New Revision: 80c3ea4e633b440cb4bc2c36856d811353e474bb

URL: 
https://github.com/llvm/llvm-project/commit/80c3ea4e633b440cb4bc2c36856d811353e474bb
DIFF: 
https://github.com/llvm/llvm-project/commit/80c3ea4e633b440cb4bc2c36856d811353e474bb.diff

LOG: Re-land "[lldb/CMake] Auto-generate the Initialize and Terminate calls for 
plugin"

This patch changes the way we initialize and terminate the plugins in
the system initializer. It uses an approach similar to LLVM's
TARGETS_TO_BUILD with a def file that enumerates the plugins.

Previous attempts to land this failed on the Windows bot because there's
a dependency between the different process plugins. Apparently
ProcessWindowsCommon needs to be initialized after all other process
plugins but before ProcessGDBRemote.

Differential revision: https://reviews.llvm.org/D73067

Added: 


Modified: 
lldb/source/API/SystemInitializerFull.cpp
lldb/source/Plugins/CMakeLists.txt
lldb/source/Plugins/Plugins.def.in
lldb/tools/lldb-test/SystemInitializerTest.cpp

Removed: 




diff  --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index dfada58700c3..7f95e7acf62a 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -30,149 +30,26 @@
 using namespace lldb_private;
 
 SystemInitializerFull::SystemInitializerFull() = default;
-
 SystemInitializerFull::~SystemInitializerFull() = default;
 
-#define LLDB_PROCESS_AArch64(op) op(ABIAArch64);
-#define LLDB_PROCESS_ARM(op) op(ABIARM);
-#define LLDB_PROCESS_ARC(op) op(ABIARC);
-#define LLDB_PROCESS_Hexagon(op) op(ABIHexagon);
-#define LLDB_PROCESS_Mips(op) op(ABIMips);
-#define LLDB_PROCESS_PowerPC(op) op(ABIPowerPC);
-#define LLDB_PROCESS_SystemZ(op) op(ABISystemZ);
-#define LLDB_PROCESS_X86(op) op(ABIX86);
-
-#define LLDB_PROCESS_AMDGPU(op)
-#define LLDB_PROCESS_AVR(op)
-#define LLDB_PROCESS_BPF(op)
-#define LLDB_PROCESS_Lanai(op)
-#define LLDB_PROCESS_MSP430(op)
-#define LLDB_PROCESS_NVPTX(op)
-#define LLDB_PROCESS_RISCV(op)
-#define LLDB_PROCESS_Sparc(op)
-#define LLDB_PROCESS_WebAssembly(op)
-#define LLDB_PROCESS_XCore(op)
-
 llvm::Error SystemInitializerFull::Initialize() {
   if (auto e = SystemInitializerCommon::Initialize())
 return e;
 
-  LLDB_PLUGIN_INITIALIZE(ObjectFileBreakpad);
-  LLDB_PLUGIN_INITIALIZE(ObjectFileELF);
-  LLDB_PLUGIN_INITIALIZE(ObjectFileJIT);
-  LLDB_PLUGIN_INITIALIZE(ObjectFileMachO);
-  LLDB_PLUGIN_INITIALIZE(ObjectFilePECOFF);
-  LLDB_PLUGIN_INITIALIZE(ObjectFileWasm);
-
-  LLDB_PLUGIN_INITIALIZE(ObjectContainerBSDArchive);
-  LLDB_PLUGIN_INITIALIZE(ObjectContainerMachOArchive);
-
-  LLDB_PLUGIN_INITIALIZE(ScriptInterpreterNone);
-
-#if LLDB_ENABLE_PYTHON
-  LLDB_PLUGIN_INITIALIZE(OperatingSystemPython);
-#endif
-
-#if LLDB_ENABLE_PYTHON
-  LLDB_PLUGIN_INITIALIZE(ScriptInterpreterPython);
-#endif
-
-#if LLDB_ENABLE_LUA
-  LLDB_PLUGIN_INITIALIZE(ScriptInterpreterLua);
-#endif
-  LLDB_PLUGIN_INITIALIZE(PlatformFreeBSD);
-  LLDB_PLUGIN_INITIALIZE(PlatformLinux);
-  LLDB_PLUGIN_INITIALIZE(PlatformNetBSD);
-  LLDB_PLUGIN_INITIALIZE(PlatformOpenBSD);
-  LLDB_PLUGIN_INITIALIZE(PlatformWindows);
-  LLDB_PLUGIN_INITIALIZE(PlatformAndroid);
-  LLDB_PLUGIN_INITIALIZE(PlatformMacOSX);
-
   // Initialize LLVM and Clang
   llvm::InitializeAllTargets();
   llvm::InitializeAllAsmPrinters();
   llvm::InitializeAllTargetMCs();
   llvm::InitializeAllDisassemblers();
 
-  LLDB_PLUGIN_INITIALIZE(TypeSystemClang);
-
-#define LLVM_TARGET(t) LLDB_PROCESS_##t(LLDB_PLUGIN_INITIALIZE)
-#include "llvm/Config/Targets.def"
-
-  LLDB_PLUGIN_INITIALIZE(ArchitectureArm);
-  LLDB_PLUGIN_INITIALIZE(ArchitectureMips);
-  LLDB_PLUGIN_INITIALIZE(ArchitecturePPC64);
-
-  LLDB_PLUGIN_INITIALIZE(DisassemblerLLVMC);
-
-  LLDB_PLUGIN_INITIALIZE(JITLoaderGDB);
-  LLDB_PLUGIN_INITIALIZE(ProcessElfCore);
-  LLDB_PLUGIN_INITIALIZE(ProcessMachCore);
-  LLDB_PLUGIN_INITIALIZE(ProcessMinidump);
-  LLDB_PLUGIN_INITIALIZE(MemoryHistoryASan);
-  LLDB_PLUGIN_INITIALIZE(InstrumentationRuntimeASan);
-  LLDB_PLUGIN_INITIALIZE(InstrumentationRuntimeTSan);
-  LLDB_PLUGIN_INITIALIZE(InstrumentationRuntimeUBSan);
-  LLDB_PLUGIN_INITIALIZE(InstrumentationRuntimeMainThreadChecker);
-
-  LLDB_PLUGIN_INITIALIZE(SymbolVendorELF);
-  LLDB_PLUGIN_INITIALIZE(SymbolFileBreakpad);
-  LLDB_PLUGIN_INITIALIZE(SymbolFileDWARF);
-  LLDB_PLUGIN_INITIALIZE(SymbolFilePDB);
-  LLDB_PLUGIN_INITIALIZE(SymbolFileSymtab);
-  LLDB_PLUGIN_INITIALIZE(SymbolVendorWasm);
-  LLDB_PLUGIN_INITIALIZE(UnwindAssemblyInstEmulation);
-  LLDB_PLUGIN_INITIALIZE(UnwindAssemblyX86);
-
-  LLDB_PLUGIN_INITIALIZE(InstructionARM);
-  LLDB_PLUGIN_INITIALIZE(InstructionARM64);
-  LLDB_PLUGIN_INITIALIZE(InstructionMIPS);
-  LLDB_PLUGIN_INITIALIZE(InstructionMIPS64);
-  LLDB_PLUGIN_INITIALIZE(InstructionPPC64);
-
-  LLDB_PLUGIN_INITIALIZE(CXXIta

[Lldb-commits] [lldb] ae73891 - [lldb/Docs] Update the Windows documentation

2020-02-18 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-18T19:53:36-08:00
New Revision: ae738911641660a63a102923c2beb070d6cebf39

URL: 
https://github.com/llvm/llvm-project/commit/ae738911641660a63a102923c2beb070d6cebf39
DIFF: 
https://github.com/llvm/llvm-project/commit/ae738911641660a63a102923c2beb070d6cebf39.diff

LOG: [lldb/Docs] Update the Windows documentation

Update the build instructions for Windows with my recent experience.

Added: 


Modified: 
lldb/docs/resources/build.rst

Removed: 




diff  --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index 285ea0144d90..277303616f30 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -34,7 +34,7 @@ If you want to run the test suite, you'll need to build LLDB 
with Python
 scripting support.
 
 * `Python `_
-* `SWIG `_
+* `SWIG `_ 2 or later.
 
 Optional Dependencies
 *
@@ -79,29 +79,38 @@ commands below.
 Windows
 ***
 
-* Visual Studio 2015 or greater
-* Windows SDK 8.0 or higher. In general it is best to use the latest available
-  version.
-* `GnuWin32 `_
-* `Python 3.5 or higher `_ or
-  higher. Earlier versions of Python can be made to work by compiling your own
-  distribution from source, but this workflow is unsupported and you are own
-  your own.
+* Visual Studio 2017.
+* The latest Windows SDK.
+* The Active Template Library (ATL).
+* `GnuWin32 `_ for CoreUtils and Make.
+* `Python 3.6 `_. Python 3.7 is
+  known to be incompatible. More recent versions might work but are untested.
+  Make sure to get the x64 variant if that's what you're targetting and install
+  the debug library if you want to build in debug.
 * `Python Tools for Visual Studio
   `_. If you plan to debug test
   failures or even write new tests at all, PTVS is an indispensable debugging
   extension to VS that enables full editing and debugging support for Python
-  (including mixed native/managed debugging)
+  (including mixed native/managed debugging).
 
 The steps outlined here describes how to set up your system and install the
 required dependencies such that they can be found when needed during the build
 process. They only need to be performed once.
 
-#. Install Visual Studio and the Windows SDK.
+#. Install Visual Studio with the Windows SDK and ATL components.
 #. Install GnuWin32, making sure ``\bin`` is added to
-   your PATH environment variable.
+   your PATH environment variable. Verify that utilities like ``dirname`` and
+   ``make`` are available from your terminal.
 #. Install SWIG for Windows, making sure  is added to
-   your PATH environment variable.
+   your PATH environment variable. Verify that ``swig`` is available from your
+   terminal.
+#. Register the Debug Interface Access DLLs with the Registry from a privileged
+   terminal.
+
+::
+
+> regsvr32 "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\DIA 
SDK\bin\msdia140.dll"
+> regsvr32 "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\DIA 
SDK\bin\amd64\msdia140.dll"
 
 Any command prompt from which you build LLDB should have a valid Visual Studio
 environment setup. This means you should run ``vcvarsall.bat`` or open an



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


[Lldb-commits] [lldb] e682058 - [lldb/Docs] Update the features matrix

2020-02-18 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-18T20:08:43-08:00
New Revision: e68205844db3079116c777f34d273149b8b74cad

URL: 
https://github.com/llvm/llvm-project/commit/e68205844db3079116c777f34d273149b8b74cad
DIFF: 
https://github.com/llvm/llvm-project/commit/e68205844db3079116c777f34d273149b8b74cad.diff

LOG: [lldb/Docs] Update the features matrix

Use YES/NO instead of OK, known issues instead of bugs and fix some
other small inconsistencies

Added: 


Modified: 
lldb/docs/status/status.rst

Removed: 




diff  --git a/lldb/docs/status/status.rst b/lldb/docs/status/status.rst
index 8a922d086764..5b7fd6635774 100644
--- a/lldb/docs/status/status.rst
+++ b/lldb/docs/status/status.rst
@@ -43,26 +43,26 @@ section below.
 
 Features Matrix
 ---
-+++-++--+--+
-| Feature| FreeBSD| Linux   | 
macOS  | NetBSD   | Windows  |
-+++=++==+==+
-| Backtracing| OK | OK  | OK   
  | OK   | OK   |
-+++-++--+--+
-| Breakpoints| OK | OK  | OK   
  | OK   | OK   |
-+++-++--+--+
-| C++11: | OK | OK  | OK   
  | OK   | Unknown  |
-+++-++--+--+
-| Commandline lldb tool  | OK | OK  | OK   
  | OK   | OK   |
-+++-++--+--+
-| Core file debugging| OK (ELF)   | OK (ELF)| OK 
(MachO) | OK   | OK (Minidump)|
-+++-++--+--+
-| Debugserver (remote debugging) | Not ported | OK (lldb-server)| OK   
  | OK (lldb-server) | Not ported   |
-+++-++--+--+
-| Disassembly| OK | OK  | OK   
  | OK   | OK   |
-+++-++--+--+
-| Expression evaluation  | Unknown| Works with some bugs| OK   
  | OK (with bugs?)  | Works with some bugs |
-+++-++--+--+
-| JIT debugging  | Unknown| Symbolic debugging only | 
Untested   | Work In Progress | No   |
-+++-++--+--+
-| Objective-C 2.0:   | Unknown| Not applicable  | OK   
  | Unknown  |Not applicable|
-+++-++--+--+
++---++-+---++--+
+| Feature   | FreeBSD| Linux   | macOS 
| NetBSD | Windows  |
++===++=+===++==+
+| Backtracing   | YES| YES | YES   
| YES| YES  |
++---++-+---++--+
+| Breakpoints   | YES| YES | YES   
| YES| YES  |
++---++-+---++--+
+| C++11:| YES| YES | YES   
| YES| Unknown  |
++---++-+---+

[Lldb-commits] [lldb] d7db094 - [lldb] Move ArchitectureCreateInstance into ldb-private-interfaces

2020-02-18 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-18T20:19:54-08:00
New Revision: d7db094ef790f16a6252ac83a48958de23851aee

URL: 
https://github.com/llvm/llvm-project/commit/d7db094ef790f16a6252ac83a48958de23851aee
DIFF: 
https://github.com/llvm/llvm-project/commit/d7db094ef790f16a6252ac83a48958de23851aee.diff

LOG: [lldb] Move ArchitectureCreateInstance into ldb-private-interfaces

There's no reason this should be the only one living in the
PluginManager itself.

Added: 


Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/include/lldb/lldb-forward.h
lldb/include/lldb/lldb-private-interfaces.h
lldb/source/Core/PluginManager.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index 90db9cee06ac..4cae597d3732 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -62,9 +62,6 @@ class PluginManager {
   static ABICreateInstance GetABICreateCallbackAtIndex(uint32_t idx);
 
   // Architecture
-  using ArchitectureCreateInstance =
-  std::unique_ptr (*)(const ArchSpec &);
-
   static void RegisterPlugin(ConstString name, llvm::StringRef description,
  ArchitectureCreateInstance create_callback);
 

diff  --git a/lldb/include/lldb/lldb-forward.h 
b/lldb/include/lldb/lldb-forward.h
index d1d02e571681..97fb20bd0b70 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -20,6 +20,7 @@ class ABI;
 class Address;
 class AddressRange;
 class AddressResolver;
+class Architecture;
 class ArchSpec;
 class ArmUnwindInfo;
 class Args;

diff  --git a/lldb/include/lldb/lldb-private-interfaces.h 
b/lldb/include/lldb/lldb-private-interfaces.h
index 5c351fa0b813..1568e7a3cb51 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -13,14 +13,16 @@
 
 #include "lldb/lldb-enumerations.h"
 #include "lldb/lldb-forward.h"
-#include "lldb/lldb-types.h"
-
 #include "lldb/lldb-private-enumerations.h"
-
+#include "lldb/lldb-types.h"
+#include 
 #include 
 
 namespace lldb_private {
-typedef lldb::ABISP (*ABICreateInstance)(lldb::ProcessSP process_sp, const 
ArchSpec &arch);
+typedef lldb::ABISP (*ABICreateInstance)(lldb::ProcessSP process_sp,
+ const ArchSpec &arch);
+typedef std::unique_ptr (*ArchitectureCreateInstance)(
+const ArchSpec &arch);
 typedef Disassembler *(*DisassemblerCreateInstance)(const ArchSpec &arch,
 const char *flavor);
 typedef DynamicLoader *(*DynamicLoaderCreateInstance)(Process *process,

diff  --git a/lldb/source/Core/PluginManager.cpp 
b/lldb/source/Core/PluginManager.cpp
index e23afecbf13f..136b1fcbcbf0 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -270,8 +270,7 @@ ABICreateInstance 
PluginManager::GetABICreateCallbackAtIndex(uint32_t idx) {
 
 #pragma mark Architecture
 
-typedef PluginInstance
-ArchitectureInstance;
+typedef PluginInstance ArchitectureInstance;
 typedef std::vector ArchitectureInstances;
 
 static std::mutex &GetArchitectureMutex() {



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


[Lldb-commits] [lldb] 7c4b704 - [lldb] Sort forward declarations in lldb-forward.h

2020-02-18 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-18T20:22:52-08:00
New Revision: 7c4b70402c6679427a5a2d4508355af7d4c61678

URL: 
https://github.com/llvm/llvm-project/commit/7c4b70402c6679427a5a2d4508355af7d4c61678
DIFF: 
https://github.com/llvm/llvm-project/commit/7c4b70402c6679427a5a2d4508355af7d4c61678.diff

LOG: [lldb] Sort forward declarations in lldb-forward.h

Sort forward declarations alphabetically. Also remove the two LLVM
forward declares as they frankly don't belong here.

Added: 


Modified: 
lldb/include/lldb/lldb-forward.h

Removed: 




diff  --git a/lldb/include/lldb/lldb-forward.h 
b/lldb/include/lldb/lldb-forward.h
index 97fb20bd0b70..bdcb69f08ce8 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -17,15 +17,15 @@
 namespace lldb_private {
 
 class ABI;
+class ASTResultSynthesizer;
+class ASTStructExtractor;
 class Address;
 class AddressRange;
 class AddressResolver;
-class Architecture;
 class ArchSpec;
-class ArmUnwindInfo;
+class Architecture;
 class Args;
-class ASTResultSynthesizer;
-class ASTStructExtractor;
+class ArmUnwindInfo;
 class Baton;
 class Block;
 class Breakpoint;
@@ -45,6 +45,7 @@ class BreakpointSiteList;
 class BroadcastEventSpec;
 class Broadcaster;
 class BroadcasterManager;
+class CXXSyntheticChildren;
 class CallFrameInfo;
 class CommandInterpreter;
 class CommandInterpreterRunOptions;
@@ -53,15 +54,13 @@ class CommandObjectMultiword;
 class CommandReturnObject;
 class Communication;
 class CompactUnwindInfo;
-struct CompilerContext;
+class CompileUnit;
 class CompilerDecl;
 class CompilerDeclContext;
 class CompilerType;
-class CompileUnit;
 class Connection;
 class ConnectionFileDescriptor;
 class ConstString;
-class CXXSyntheticChildren;
 class DWARFCallFrameInfo;
 class DWARFDataExtractor;
 class DWARFExpression;
@@ -77,7 +76,6 @@ class DynamicCheckerFunctions;
 class DynamicLoader;
 class Editline;
 class EmulateInstruction;
-class Status;
 class EvaluateExpressionOptions;
 class Event;
 class EventData;
@@ -86,26 +84,26 @@ class ExecutionContext;
 class ExecutionContextRef;
 class ExecutionContextScope;
 class Expression;
+class ExpressionTypeSystemHelper;
 class ExpressionVariable;
 class ExpressionVariableList;
-class ExpressionTypeSystemHelper;
 class File;
 class FileSpec;
 class FileSpecList;
 class Flags;
-class TypeCategoryImpl;
 class FormatManager;
 class FormattersMatchCandidate;
 class FuncUnwinders;
 class Function;
+class FunctionCaller;
 class FunctionInfo;
+class IOHandler;
+class IOObject;
+class IRExecutionUnit;
 class InlineFunctionInfo;
 class Instruction;
 class InstructionList;
 class InstrumentationRuntime;
-class IOHandler;
-class IOObject;
-class IRExecutionUnit;
 class JITLoader;
 class JITLoaderList;
 class Language;
@@ -123,15 +121,13 @@ class Module;
 class ModuleList;
 class ModuleSpec;
 class ModuleSpecList;
-struct NameSearchContext;
 class ObjectContainer;
-class OptionGroup;
-class OptionGroupOptions;
-class OptionGroupPlatform;
 class ObjectFile;
 class ObjectFileJITDelegate;
 class OperatingSystem;
-class Options;
+class OptionGroup;
+class OptionGroupOptions;
+class OptionGroupPlatform;
 class OptionValue;
 class OptionValueArch;
 class OptionValueArgs;
@@ -143,8 +139,8 @@ class OptionValueEnumeration;
 class OptionValueFileSpec;
 class OptionValueFileSpecList;
 class OptionValueFormat;
-class OptionValueLanguage;
 class OptionValueFormatEntity;
+class OptionValueLanguage;
 class OptionValuePathMappings;
 class OptionValueProperties;
 class OptionValueRegex;
@@ -152,31 +148,33 @@ class OptionValueSInt64;
 class OptionValueString;
 class OptionValueUInt64;
 class OptionValueUUID;
+class Options;
 class PathMappingList;
-class FunctionCaller;
 class PersistentExpressionState;
 class Platform;
 class Process;
 class ProcessAttachInfo;
-class ProcessModID;
 class ProcessInfo;
 class ProcessInstanceInfo;
 class ProcessInstanceInfoList;
 class ProcessInstanceInfoMatch;
 class ProcessLaunchInfo;
+class ProcessModID;
 class Property;
-struct PropertyDefinition;
+class Queue;
+class QueueImpl;
+class QueueItem;
+class REPL;
 class RecognizedStackFrame;
 class RegisterCheckpoint;
 class RegisterContext;
 class RegisterValue;
 class RegularExpression;
-class REPL;
 class RichManglingContext;
 class Scalar;
 class ScriptInterpreter;
 class ScriptInterpreterLocker;
-struct ScriptSummaryFormat;
+class ScriptedSyntheticChildren;
 class SearchFilter;
 class Section;
 class SectionList;
@@ -190,21 +188,17 @@ class StackFrameList;
 class StackFrameRecognizer;
 class StackFrameRecognizerManager;
 class StackID;
+class Status;
 class StopInfo;
 class Stoppoint;
 class StoppointCallbackContext;
 class StoppointLocation;
 class Stream;
-template  class StreamBuffer;
 class StreamFile;
 class StreamString;
 class StringList;
-struct StringSummaryFormat;
 class StructuredDataImpl;
 class StructuredDataPlugin;
-class SystemRunt

[Lldb-commits] [PATCH] D74727: Allow customized relative PYTHONHOME

2020-02-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

In D74727#1881055 , @hhb wrote:

> > Can we maybe rename it to something like that?
>
> LLDB_RELOCATABLE_PYTHON is misleading. I'd be happy to rename it. But that 
> may break people who already set this flag.
>
> Is there a standard procedure to do this? Maybe add the new one and remove 
> the old one a year later? Or maybe fail when the old is set. So that at least 
> people know how to fix?


We've made breaking changes like that in the past. This might even be a good 
thing when we're changing behavior.

> 
> 
>> Or maybe even just a single LLDB_PYTHON_HOME variable, with the empty value 
>> meaning we use the default python mechanism (PYTHONHOME env var, or the 
>> baked-in python default)?
> 
> To do that, we have to make LLDB_PYTHON_HOME default to PYTHON_HOME for 
> Windows. And if windows users want to make it "relocatable", they should set 
> LLDB_PYTHON_HOME back to empty. That's also somehow weird...

Another alternative would be to default to "Auto", like we do with the optional 
dependencies, in which case it would default to PYTHON_HOME. Empty would always 
signal a relocatable python.

>> The other thing which bugs me is that the relative python path chosen here 
>> will likely only be correct once lldb is installed. Will it be possible to 
>> run lldb (and its test suite) configured in this way directly from the build 
>> tree? I don't know if there's anything we can or should do about that, but 
>> this situation seems less than ideal...
> 
> If someone uses relative python, that mean they should be responsible to put 
> Python at the right place. No matter it is build tree or install tree. Or in 
> other words, the install tree won't work by default either. People still need 
> to put a symlink to python at the right place.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74727



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


[Lldb-commits] [PATCH] D74798: [lldb-vscode] Use libOption with tablegen to parse command line options.

2020-02-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM with the inline comments addressed and a test in `Shell/VSCode`.




Comment at: lldb/tools/lldb-vscode/CMakeLists.txt:20
 
+
 # We need to include the llvm components we depend on manually, as liblldb does

Spurious newline



Comment at: lldb/tools/lldb-vscode/CMakeLists.txt:25
+set(LLVM_TARGET_DEFINITIONS Opts.td)
+tablegen(LLVM Opts.inc -gen-opt-parser-defs)
+add_public_tablegen_target(LLDBVSCodeOptionsTableGen)

Please use `Options.td` for consistency with the lldb driver.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74798



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


[Lldb-commits] [PATCH] D74816: [lldb/Core] Remove more duplicate code in PluginManager (NFCI)

2020-02-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: labath, teemperor.
Herald added a subscriber: abidh.
Herald added a project: LLDB.
JDevlieghere edited the summary of this revision.
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM, let’s send that code to the shadow realm.


The PluginManager contains a lot of duplicate code. I already removed a bunch 
of it by introducing a the templated PluginInstance class, and this is the next 
step in the process.

There's a lot more that can be done, but for these kind of changes I like to 
work incrementally. Given that this touches a lot of code I'd appreciate a 
second set of eyes to spot any mistakes.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D74816

Files:
  lldb/source/Core/PluginManager.cpp

Index: lldb/source/Core/PluginManager.cpp
===
--- lldb/source/Core/PluginManager.cpp
+++ lldb/source/Core/PluginManager.cpp
@@ -16,38 +16,24 @@
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StringList.h"
-
-#if defined(_WIN32)
-#include "lldb/Host/windows/PosixApi.h"
-#endif
-
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/raw_ostream.h"
-
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-
-#include 
-
-namespace lldb_private {
-class CommandInterpreter;
-}
+#if defined(_WIN32)
+#include "lldb/Host/windows/PosixApi.h"
+#endif
 
 using namespace lldb;
 using namespace lldb_private;
 
-enum PluginAction {
-  ePluginRegisterInstance,
-  ePluginUnregisterInstance,
-  ePluginGetInstanceAtIndex
-};
-
 typedef bool (*PluginInitCallback)();
 typedef void (*PluginTermCallback)();
 
@@ -92,7 +78,6 @@
 static FileSystem::EnumerateDirectoryResult
 LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
llvm::StringRef path) {
-  //PluginManager *plugin_manager = (PluginManager *)baton;
   Status error;
 
   namespace fs = llvm::sys::fs;
@@ -156,7 +141,6 @@
 }
 
 void PluginManager::Initialize() {
-#if 1
   const bool find_directories = true;
   const bool find_files = true;
   const bool find_other = true;
@@ -178,7 +162,6 @@
 LoadPluginCallback, nullptr);
 }
   }
-#endif
 }
 
 void PluginManager::Terminate() {
@@ -198,6 +181,8 @@
 }
 
 template  struct PluginInstance {
+  typedef Callback CallbackType;
+
   PluginInstance() = default;
   PluginInstance(ConstString name, std::string description,
  Callback create_callback = nullptr,
@@ -212,16 +197,97 @@
   DebuggerInitializeCallback debugger_init_callback;
 };
 
-#pragma mark ABI
+template  class PluginInstances {
+public:
+  template 
+  bool RegisterPlugin(ConstString name, const char *description,
+  typename Instance::CallbackType callback,
+  Args &&... args) {
+if (!callback)
+  return false;
 
-typedef PluginInstance ABIInstance;
+assert((bool)name);
+Instance instance =
+Instance(name, description, callback, std::forward(args)...);
+std::lock_guard guard(m_mutex);
+m_instances.push_back(instance);
+return false;
+  }
 
-typedef std::vector ABIInstances;
+  bool UnregisterPlugin(typename Instance::CallbackType callback) {
+if (!callback)
+  return false;
+std::lock_guard guard(m_mutex);
+auto pos = m_instances.begin();
+auto end = m_instances.end();
+for (; pos != end; ++pos) {
+  if (pos->create_callback == callback) {
+m_instances.erase(pos);
+return true;
+  }
+}
+return false;
+  }
 
-static std::recursive_mutex &GetABIInstancesMutex() {
-  static std::recursive_mutex g_instances_mutex;
-  return g_instances_mutex;
-}
+  typename Instance::CallbackType GetCallbackAtIndex(uint32_t idx) {
+std::lock_guard guard(m_mutex);
+if (Instance *instance = GetInstanceAtIndex(idx))
+  return instance->create_callback;
+return nullptr;
+  }
+
+  const char *GetDescriptionAtIndex(uint32_t idx) {
+std::lock_guard guard(m_mutex);
+if (Instance *instance = GetInstanceAtIndex(idx))
+  return instance->description.c_str();
+return nullptr;
+  }
+
+  const char *GetNameAtIndex(uint32_t idx) {
+std::lock_guard guard(m_mutex);
+if (Instance *instance = GetInstanceAtIndex(idx))
+  return instance->name.GetCString();
+return nullptr;
+  }
+
+  typename Instance::CallbackType GetCallbackForName(ConstString name) {
+if (!name)
+  return nullptr;
+std::lock_guard guard(m_mutex);
+for (auto &instance : m_instances) {
+  if (name == instance.name)
+return instance.create_callback;
+}
+return nullptr;
+  }
+
+  void PerformDebuggerCallback(Debugger &debugger) {
+std::lock_guard guard(m_mutex);
+for (auto &instance : m_i

[Lldb-commits] [PATCH] D74816: [lldb/Core] Remove more duplicate code in PluginManager (NFCI)

2020-02-18 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM, let’s send that code to the shadow realm.


Repository:
  rLLDB LLDB

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

https://reviews.llvm.org/D74816



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


[Lldb-commits] [lldb] 80b2e3c - [lldb/Core] Remove more duplicate code in PluginManager (NFCI)

2020-02-18 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2020-02-18T23:58:29-08:00
New Revision: 80b2e3cc531206c6e6f23dcc49b83b9ace641025

URL: 
https://github.com/llvm/llvm-project/commit/80b2e3cc531206c6e6f23dcc49b83b9ace641025
DIFF: 
https://github.com/llvm/llvm-project/commit/80b2e3cc531206c6e6f23dcc49b83b9ace641025.diff

LOG: [lldb/Core] Remove more duplicate code in PluginManager (NFCI)

The PluginManager contains a lot of duplicate code. I already removed a
bunch of it by introducing the templated PluginInstance class, and this
is the next step. The PluginInstances class combines the mutex and the
vector and implements the common operations.

To accommodate plugin instances with additional members it is possible
to access the underlying vector and mutex. The methods to query these
fields make use of that.

Differential revision: https://reviews.llvm.org/D74816

Added: 


Modified: 
lldb/source/Core/PluginManager.cpp

Removed: 




diff  --git a/lldb/source/Core/PluginManager.cpp 
b/lldb/source/Core/PluginManager.cpp
index 136b1fcbcbf0..de723284135c 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -16,38 +16,24 @@
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/StringList.h"
-
-#if defined(_WIN32)
-#include "lldb/Host/windows/PosixApi.h"
-#endif
-
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/raw_ostream.h"
-
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-
-#include 
-
-namespace lldb_private {
-class CommandInterpreter;
-}
+#if defined(_WIN32)
+#include "lldb/Host/windows/PosixApi.h"
+#endif
 
 using namespace lldb;
 using namespace lldb_private;
 
-enum PluginAction {
-  ePluginRegisterInstance,
-  ePluginUnregisterInstance,
-  ePluginGetInstanceAtIndex
-};
-
 typedef bool (*PluginInitCallback)();
 typedef void (*PluginTermCallback)();
 
@@ -92,7 +78,6 @@ template  static FPtrTy CastToFPtr(void 
*VPtr) {
 static FileSystem::EnumerateDirectoryResult
 LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
llvm::StringRef path) {
-  //PluginManager *plugin_manager = (PluginManager *)baton;
   Status error;
 
   namespace fs = llvm::sys::fs;
@@ -156,7 +141,6 @@ LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
 }
 
 void PluginManager::Initialize() {
-#if 1
   const bool find_directories = true;
   const bool find_files = true;
   const bool find_other = true;
@@ -178,7 +162,6 @@ void PluginManager::Initialize() {
 LoadPluginCallback, nullptr);
 }
   }
-#endif
 }
 
 void PluginManager::Terminate() {
@@ -198,6 +181,8 @@ void PluginManager::Terminate() {
 }
 
 template  struct PluginInstance {
+  typedef Callback CallbackType;
+
   PluginInstance() = default;
   PluginInstance(ConstString name, std::string description,
  Callback create_callback = nullptr,
@@ -212,16 +197,97 @@ template  struct PluginInstance {
   DebuggerInitializeCallback debugger_init_callback;
 };
 
-#pragma mark ABI
+template  class PluginInstances {
+public:
+  template 
+  bool RegisterPlugin(ConstString name, const char *description,
+  typename Instance::CallbackType callback,
+  Args &&... args) {
+if (!callback)
+  return false;
 
-typedef PluginInstance ABIInstance;
+assert((bool)name);
+Instance instance =
+Instance(name, description, callback, std::forward(args)...);
+std::lock_guard guard(m_mutex);
+m_instances.push_back(instance);
+return false;
+  }
 
-typedef std::vector ABIInstances;
+  bool UnregisterPlugin(typename Instance::CallbackType callback) {
+if (!callback)
+  return false;
+std::lock_guard guard(m_mutex);
+auto pos = m_instances.begin();
+auto end = m_instances.end();
+for (; pos != end; ++pos) {
+  if (pos->create_callback == callback) {
+m_instances.erase(pos);
+return true;
+  }
+}
+return false;
+  }
 
-static std::recursive_mutex &GetABIInstancesMutex() {
-  static std::recursive_mutex g_instances_mutex;
-  return g_instances_mutex;
-}
+  typename Instance::CallbackType GetCallbackAtIndex(uint32_t idx) {
+std::lock_guard guard(m_mutex);
+if (Instance *instance = GetInstanceAtIndex(idx))
+  return instance->create_callback;
+return nullptr;
+  }
+
+  const char *GetDescriptionAtIndex(uint32_t idx) {
+std::lock_guard guard(m_mutex);
+if (Instance *instance = GetInstanceAtIndex(idx))
+  return instance->description.c_str();
+return nullptr;
+  }
+
+  const char *GetNameAtIndex(uint32_t idx) {
+std::lock_guard guard(m_mutex);
+if (Instance *instance = GetInstanceAtIndex(idx))
+  return instance->name.GetCString();
+return nullptr;
+  }
+
+  typename