[Lldb-commits] [PATCH] D143698: Cleanedup and added comments

2023-02-10 Thread Kamlesh Kumar via Phabricator via lldb-commits
kkcode0 updated this revision to Diff 496360.
kkcode0 added a comment.

rebased with main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143698

Files:
  lldb/include/lldb/Host/common/NativeRegisterContext.h
  lldb/include/lldb/Target/RegisterContext.h
  lldb/include/lldb/Utility/StringExtractorGDBRemote.h
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Host/common/NativeRegisterContext.cpp
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/source/Target/RegisterContext.cpp
  lldb/source/Target/Thread.cpp
  lldb/source/Utility/StringExtractorGDBRemote.cpp

Index: lldb/source/Utility/StringExtractorGDBRemote.cpp
===
--- lldb/source/Utility/StringExtractorGDBRemote.cpp
+++ lldb/source/Utility/StringExtractorGDBRemote.cpp
@@ -210,6 +210,8 @@
 return eServerPacketType_qGetProfileData;
   if (PACKET_MATCHES("qGDBServerVersion"))
 return eServerPacketType_qGDBServerVersion;
+  if (PACKET_STARTS_WITH("qGetTLSAddr"))
+	  return eServerPacketType_qGetTLSAddr;
   break;
 
 case 'H':
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -1647,7 +1647,11 @@
 
 void Thread::SettingsTerminate() {}
 
-lldb::addr_t Thread::GetThreadPointer() { return LLDB_INVALID_ADDRESS; }
+lldb::addr_t Thread::GetThreadPointer() {
+  RegisterContext *reg_ctx = this->GetRegisterContext().get();
+  auto tp = reg_ctx->GetThreadPointer();
+  return tp;
+}
 
 addr_t Thread::GetThreadLocalData(const ModuleSP module,
   lldb::addr_t tls_file_addr) {
Index: lldb/source/Target/RegisterContext.cpp
===
--- lldb/source/Target/RegisterContext.cpp
+++ lldb/source/Target/RegisterContext.cpp
@@ -29,6 +29,10 @@
 
 RegisterContext::~RegisterContext() = default;
 
+uint64_t RegisterContext::GetThreadPointer() {
+  return UINT64_MAX;
+}
+
 void RegisterContext::InvalidateIfNeeded(bool force) {
   ProcessSP process_sp(m_thread.GetProcess());
   bool invalidate = force;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
@@ -55,6 +55,8 @@
 
   const RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override;
 
+  uint64_t GetThreadPointer() override;
+
   size_t GetRegisterSetCount() override;
 
   const RegisterSet *GetRegisterSet(size_t reg_set) override;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -80,6 +80,19 @@
   return m_reg_info_sp->GetRegisterSet(reg_set);
 }
 
+uint64_t GDBRemoteRegisterContext::GetThreadPointer() {
+  ExecutionContext exe_ctx(CalculateThread());
+  Process *process = exe_ctx.GetProcessPtr();
+  Thread *thread = exe_ctx.GetThreadPtr();
+  if (process == nullptr || thread == nullptr)
+return LLDB_INVALID_ADDRESS;
+  GDBRemoteCommunicationClient &gdb_comm(
+  ((ProcessGDBRemote *)process)->GetGDBRemote());
+  uint64_t tid = thread->GetProtocolID();
+  // Return thread pointer here, offset and link_map will be filled by GetThreadLocalData in DYLD
+  return gdb_comm.GetQGetTLSAddr(tid, LLDB_INVALID_ADDRESS /* offset */, LLDB_INVALID_ADDRESS /* lm */);
+}
+
 bool GDBRemoteRegisterContext::ReadRegister(const RegisterInfo *reg_info,
 RegisterValue &value) {
   // Read the register
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
@@ 

[Lldb-commits] [lldb] d768bf9 - [NFC][TargetParser] Replace uses of llvm/Support/Host.h

2023-02-10 Thread Archibald Elliott via lldb-commits

Author: Archibald Elliott
Date: 2023-02-10T09:59:46Z
New Revision: d768bf994f508d7eaf9541a568be3d71096febf5

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

LOG: [NFC][TargetParser] Replace uses of llvm/Support/Host.h

The forwarding header is left in place because of its use in
`polly/lib/External/isl/interface/extract_interface.cc`, but I have
added a GCC warning about the fact it is deprecated, because it is used
in `isl` from where it is included by Polly.

Added: 


Modified: 
clang-tools-extra/clangd/Feature.cpp
clang-tools-extra/modularize/CoverageChecker.h
clang/lib/Driver/Distro.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/OffloadBundler.cpp
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/lib/Driver/ToolChains/Arch/CSKY.cpp
clang/lib/Driver/ToolChains/Arch/M68k.cpp
clang/lib/Driver/ToolChains/Arch/PPC.cpp
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/lib/Driver/ToolChains/Arch/Sparc.cpp
clang/lib/Driver/ToolChains/Arch/SystemZ.cpp
clang/lib/Driver/ToolChains/Arch/X86.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Cuda.cpp
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/CreateInvocationFromCommandLine.cpp
clang/lib/Interpreter/Interpreter.cpp
clang/lib/Tooling/CompilationDatabase.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
clang/lib/Tooling/DumpTool/ClangSrcLocDump.cpp
clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
clang/lib/Tooling/JSONCompilationDatabase.cpp
clang/lib/Tooling/Tooling.cpp
clang/tools/clang-import-test/clang-import-test.cpp
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
clang/tools/clang-scan-deps/ClangScanDeps.cpp
clang/tools/driver/cc1as_main.cpp
clang/tools/driver/cc1gen_reproducer_main.cpp
clang/tools/driver/driver.cpp
clang/unittests/AST/StructuralEquivalenceTest.cpp
clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
clang/unittests/CodeGen/BufferSourceTest.cpp
clang/unittests/CodeGen/CodeGenExternalTest.cpp
clang/unittests/CodeGen/TestCompiler.h
clang/unittests/Driver/DistroTest.cpp
clang/unittests/Driver/SanitizerArgsTest.cpp
clang/unittests/Frontend/CompilerInvocationTest.cpp
clang/unittests/Interpreter/IncrementalProcessingTest.cpp
clang/unittests/Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp
clang/unittests/Tooling/ToolingTest.cpp
flang/lib/Frontend/CompilerInvocation.cpp
flang/lib/Optimizer/Support/FIRContext.cpp
flang/tools/bbc/bbc.cpp
flang/tools/flang-driver/driver.cpp
flang/unittests/Frontend/FrontendActionTest.cpp
flang/unittests/Optimizer/FIRContextTest.cpp
libc/benchmarks/LibcBenchmark.cpp
lld/ELF/DriverUtils.cpp
lld/MachO/Driver.cpp
lld/MinGW/Driver.cpp
lld/tools/lld/lld.cpp
lld/wasm/Driver.cpp
lldb/source/Host/common/HostInfoBase.cpp
lldb/source/Host/freebsd/Host.cpp
lldb/source/Host/macosx/objcxx/Host.mm
lldb/source/Host/netbsd/HostNetBSD.cpp
lldb/source/Host/openbsd/Host.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp
lldb/unittests/Host/HostInfoTest.cpp
lldb/utils/lit-cpuid/lit-cpuid.cpp
llvm/examples/Kaleidoscope/Chapter8/toy.cpp
llvm/examples/Kaleidoscope/Chapter9/toy.cpp
llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
llvm/include/llvm/ObjectYAML/DWARFEmitter.h
llvm/include/llvm/ProfileData/InstrProf.h
llvm/include/llvm/Support/Host.h
llvm/lib/CodeGen/CommandFlags.cpp
llvm/lib/ExecutionEngine/ExecutionEngine.cpp
llvm/lib/ExecutionEngine/Orc/ExecutorProcessControl.cpp
llvm/lib/ExecutionEngine/Orc/JITTargetMachineBuilder.cpp
llvm/lib/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.cpp
llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
llvm/lib/ExecutionEngine/TargetSelect.cpp
llvm/lib/LTO/LTOCodeGenerator.cpp
llvm/lib/LTO/LTOModule.cpp
llvm/lib/MC/ELFObjectWriter.cpp
llvm/lib/Object/Archive.cpp
llvm/lib/Object/MachOObjectFile.cpp
llvm/lib/ObjectYAML/DWARFEmitter.cpp
llvm/lib/ObjectYAML/MachOYAML.cpp
llvm/lib/Target/BP

[Lldb-commits] [lldb] baca3c1 - Move SIMD alignment calculation to LLVM Frontend

2023-02-10 Thread Dominik Adamski via lldb-commits

Author: Dominik Adamski
Date: 2023-02-10T04:11:54-06:00
New Revision: baca3c150733c89686287ba4927c351eec9695e2

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

LOG: Move SIMD alignment calculation to LLVM Frontend

Currently default simd alignment is defined by Clang specific TargetInfo class.
This class cannot be reused for LLVM Flang. That's why default simd alignment
calculation has been moved to OMPIRBuilder which is common for Flang and Clang.

Previous attempt: https://reviews.llvm.org/D138496 was wrong because
the default alignment depended on the number of built LLVM targets.

If we wanted to calculate the default alignment for PPC and we hadn't specified
PPC LLVM target to build, then we would get 0 as the alignment because
OMPIRBuilder couldn't create PPCTargetMachine object and it returned 0 as
the default value.

If PPC LLVM target had been built earlier, then OMPIRBuilder could have created
PPCTargetMachine object and it would have returned 128.

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

Reviewed By: jdoerfert

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/CMakeLists.txt
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/PPC.h
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Basic/Targets/X86.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 7b6daa0c36724..1bdee3f416a90 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -225,7 +225,6 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   bool HasStrictFP;
 
   unsigned char MaxAtomicPromoteWidth, MaxAtomicInlineWidth;
-  unsigned short SimdDefaultAlign;
   std::string DataLayoutString;
   const char *UserLabelPrefix;
   const char *MCountName;
@@ -794,10 +793,6 @@ class TargetInfo : public virtual TransferrableTargetInfo,
 
   /// Return the maximum vector alignment supported for the given target.
   unsigned getMaxVectorAlign() const { return MaxVectorAlign; }
-  /// Return default simd alignment for the given target. Generally, this
-  /// value is type-specific, but this alignment can be used for most of the
-  /// types for the given target.
-  unsigned getSimdDefaultAlign() const { return SimdDefaultAlign; }
 
   unsigned getMaxOpenCLWorkGroupSize() const { return MaxOpenCLWorkGroupSize; }
 

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index beb66543cac48..a188837d4144c 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -77,6 +77,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/Support/Capacity.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
@@ -2539,7 +2540,8 @@ unsigned ASTContext::getTypeUnadjustedAlign(const Type 
*T) const {
 }
 
 unsigned ASTContext::getOpenMPDefaultSimdAlign(QualType T) const {
-  unsigned SimdAlign = getTargetInfo().getSimdDefaultAlign();
+  unsigned SimdAlign = llvm::OpenMPIRBuilder::getOpenMPDefaultSimdAlign(
+  getTargetInfo().getTriple(), Target->getTargetOpts().FeatureMap);
   return SimdAlign;
 }
 

diff  --git a/clang/lib/AST/CMakeLists.txt b/clang/lib/AST/CMakeLists.txt
index 3d8d8cc077615..0b737626a2201 100644
--- a/clang/lib/AST/CMakeLists.txt
+++ b/clang/lib/AST/CMakeLists.txt
@@ -132,4 +132,5 @@ add_clang_library(clangAST
   ClangAttrDocTable
   Opcodes
   omp_gen
+  intrinsics_gen
   )

diff  --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 70a15eb68f4ea..07af6c07031bd 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -119,7 +119,6 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : Triple(T) {
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 0;
   MaxVectorAlign = 0;
   MaxTLSAlign = 0;
-  SimdDefaultAlign = 0;
   SizeType = UnsignedLong;
   PtrDiffType = SignedLong;
   IntMaxType = SignedLongLong;

diff  --git a/clang/lib/Basic/Targets/PPC.h b/clang/lib/Basic/Targets/PPC.h
index ebf0c2d0506d8..79f5d6e8c720b 100644
--- a/clang/lib/Basic/Targets/PPC.h
+++ b/clang/lib/Basic/Targets/PPC.h
@@ -87,7 +87,6 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public 
TargetInfo {
   PPCTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple) {
 SuitableAlign = 128;
-SimdDefaultAlign = 128;
 LongDoubleWidth = LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::PPCD

[Lldb-commits] [PATCH] D141910: [OpenMP][OMPIRBuilder]Move SIMD alignment calculation to LLVM Frontend

2023-02-10 Thread Dominik Adamski via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbaca3c150733: Move SIMD alignment calculation to LLVM 
Frontend (authored by domada).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141910

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/CMakeLists.txt
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/WebAssembly.h
  clang/lib/Basic/Targets/X86.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -3053,6 +3053,23 @@
   Builder.CreateBr(NewBlocks.front());
 }
 
+unsigned
+OpenMPIRBuilder::getOpenMPDefaultSimdAlign(const Triple &TargetTriple,
+   const StringMap &Features) {
+  if (TargetTriple.isX86()) {
+if (Features.lookup("avx512f"))
+  return 512;
+else if (Features.lookup("avx"))
+  return 256;
+return 128;
+  }
+  if (TargetTriple.isPPC())
+return 128;
+  if (TargetTriple.isWasm())
+return 128;
+  return 0;
+}
+
 void OpenMPIRBuilder::applySimd(CanonicalLoopInfo *CanonicalLoop,
 MapVector AlignedVars,
 Value *IfCond, OrderKind Order,
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -502,6 +502,13 @@
ArrayRef Loops,
InsertPointTy ComputeIP);
 
+  /// Get the default alignment value for given target
+  ///
+  /// \param TargetTriple   Target triple
+  /// \param Features   StringMap which describes extra CPU features
+  static unsigned getOpenMPDefaultSimdAlign(const Triple &TargetTriple,
+const StringMap &Features);
+
 private:
   /// Modifies the canonical loop to be a statically-scheduled workshare loop.
   ///
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -500,8 +500,6 @@
   auto target_info = TargetInfo::CreateTargetInfo(
   m_compiler->getDiagnostics(), m_compiler->getInvocation().TargetOpts);
   if (log) {
-LLDB_LOGF(log, "Using SIMD alignment: %d",
-  target_info->getSimdDefaultAlign());
 LLDB_LOGF(log, "Target datalayout string: '%s'",
   target_info->getDataLayoutString());
 LLDB_LOGF(log, "Target ABI: '%s'", target_info->getABI().str().c_str());
Index: clang/lib/Basic/Targets/X86.cpp
===
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -400,9 +400,6 @@
 return false;
   }
 
-  SimdDefaultAlign =
-  hasFeature("avx512f") ? 512 : hasFeature("avx") ? 256 : 128;
-
   // FIXME: We should allow long double type on 32-bits to match with GCC.
   // This requires backend to be able to lower f80 without x87 first.
   if (!HasX87 && LongDoubleFormat == &llvm::APFloat::x87DoubleExtended())
Index: clang/lib/Basic/Targets/WebAssembly.h
===
--- clang/lib/Basic/Targets/WebAssembly.h
+++ clang/lib/Basic/Targets/WebAssembly.h
@@ -49,7 +49,6 @@
 SuitableAlign = 128;
 LargeArrayMinWidth = 128;
 LargeArrayAlign = 128;
-SimdDefaultAlign = 128;
 SigAtomicType = SignedLong;
 LongDoubleWidth = LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
Index: clang/lib/Basic/Targets/PPC.h
===
--- clang/lib/Basic/Targets/PPC.h
+++ clang/lib/Basic/Targets/PPC.h
@@ -87,7 +87,6 @@
   PPCTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple) {
 SuitableAlign = 128;
-SimdDefaultAlign = 128;
 LongDoubleWidth = LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::PPCDoubleDouble();
 HasStrictFP = true;
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -119,7 +119,6 @@
   MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 0;
   MaxVectorAlign = 0;
   MaxTLSAlign = 0;
-  SimdDefaultAlign = 0;
   SizeType = UnsignedLong;
   PtrDiffType = S

[Lldb-commits] [PATCH] D143698: Support Debugging TLS variable with lldb

2023-02-10 Thread Kamlesh Kumar via Phabricator via lldb-commits
kkcode0 updated this revision to Diff 496392.
kkcode0 added a comment.

enabled the tls test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143698

Files:
  lldb/include/lldb/Host/common/NativeRegisterContext.h
  lldb/include/lldb/Target/RegisterContext.h
  lldb/include/lldb/Utility/StringExtractorGDBRemote.h
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Host/common/NativeRegisterContext.cpp
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/source/Target/RegisterContext.cpp
  lldb/source/Target/Thread.cpp
  lldb/source/Utility/StringExtractorGDBRemote.cpp
  lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py

Index: lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py
===
--- lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py
+++ lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py
@@ -35,11 +35,7 @@
 
 # TLS works differently on Windows, this would need to be implemented
 # separately.
-@skipIfWindows
-@expectedFailureAll(
-bugnumber="llvm.org/pr28392",
-oslist=no_match(
-lldbplatformutil.getDarwinOSTriples()))
+@skipIf(archs=no_match(['x86_64']), oslist=no_match(['linux']))
 def test(self):
 """Test thread-local storage."""
 self.build()
Index: lldb/source/Utility/StringExtractorGDBRemote.cpp
===
--- lldb/source/Utility/StringExtractorGDBRemote.cpp
+++ lldb/source/Utility/StringExtractorGDBRemote.cpp
@@ -210,6 +210,8 @@
 return eServerPacketType_qGetProfileData;
   if (PACKET_MATCHES("qGDBServerVersion"))
 return eServerPacketType_qGDBServerVersion;
+  if (PACKET_STARTS_WITH("qGetTLSAddr"))
+	  return eServerPacketType_qGetTLSAddr;
   break;
 
 case 'H':
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -1647,7 +1647,11 @@
 
 void Thread::SettingsTerminate() {}
 
-lldb::addr_t Thread::GetThreadPointer() { return LLDB_INVALID_ADDRESS; }
+lldb::addr_t Thread::GetThreadPointer() {
+  RegisterContext *reg_ctx = this->GetRegisterContext().get();
+  auto tp = reg_ctx->GetThreadPointer();
+  return tp;
+}
 
 addr_t Thread::GetThreadLocalData(const ModuleSP module,
   lldb::addr_t tls_file_addr) {
Index: lldb/source/Target/RegisterContext.cpp
===
--- lldb/source/Target/RegisterContext.cpp
+++ lldb/source/Target/RegisterContext.cpp
@@ -29,6 +29,10 @@
 
 RegisterContext::~RegisterContext() = default;
 
+uint64_t RegisterContext::GetThreadPointer() {
+  return UINT64_MAX;
+}
+
 void RegisterContext::InvalidateIfNeeded(bool force) {
   ProcessSP process_sp(m_thread.GetProcess());
   bool invalidate = force;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
@@ -55,6 +55,8 @@
 
   const RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override;
 
+  uint64_t GetThreadPointer() override;
+
   size_t GetRegisterSetCount() override;
 
   const RegisterSet *GetRegisterSet(size_t reg_set) override;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -80,6 +80,19 @@
   return m_reg_info_sp->GetRegisterSet(reg_set);
 }
 
+uint64_t GDBRemoteRegisterContext::GetThreadPointer() {
+  ExecutionContext exe_ctx(CalculateThread());
+  Process *process = exe_ctx.GetProcessPtr();
+  Thread *thread = exe_ctx.GetThreadPtr();
+  if (process == nullptr || thread == nullptr)
+return LLDB_INVALID_ADDRESS;
+  GDBRemoteCommunicationClient &gdb_comm(
+  ((ProcessGDBRemote *)process)->GetGDBRemote());
+  u

[Lldb-commits] [PATCH] D143727: [Test][lldb] Fix YAML mapping keys duplication. NFC.

2023-02-10 Thread Anton Sidorenko via Phabricator via lldb-commits
asi-sc created this revision.
Herald added a project: All.
asi-sc requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

YAML specification does not allow keys duplication an a mapping. However, YAML
parser in LLVM does not have any check on that and uses only the last key entry.
In this change duplicated keys are merged to satisfy the spec.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143727

Files:
  lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad-decoy.yaml
  
lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad-overflow.yaml
  lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad.yaml


Index: lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad.yaml
===
--- lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad.yaml
+++ lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad.yaml
@@ -5,7 +5,6 @@
   Type:ET_DYN
   Machine: EM_ARM
   Flags:   [ EF_ARM_SOFT_FLOAT, EF_ARM_EABI_VER5 ]
-Sections:
 Sections:
   - Name:.text
 Type:SHT_PROGBITS
Index: 
lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad-overflow.yaml
===
--- 
lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad-overflow.yaml
+++ 
lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad-overflow.yaml
@@ -5,7 +5,6 @@
   Type:ET_DYN
   Machine: EM_ARM
   Flags:   [ EF_ARM_SOFT_FLOAT, EF_ARM_EABI_VER5 ]
-Sections:
 Sections:
   - Name:.text
 Type:SHT_PROGBITS
Index: 
lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad-decoy.yaml
===
--- lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad-decoy.yaml
+++ lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad-decoy.yaml
@@ -8,7 +8,6 @@
   Type:ET_DYN
   Machine: EM_ARM
   Flags:   [ EF_ARM_SOFT_FLOAT, EF_ARM_EABI_VER5 ]
-Sections:
 Sections:
   - Name:.text
 Type:SHT_PROGBITS


Index: lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad.yaml
===
--- lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad.yaml
+++ lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad.yaml
@@ -5,7 +5,6 @@
   Type:ET_DYN
   Machine: EM_ARM
   Flags:   [ EF_ARM_SOFT_FLOAT, EF_ARM_EABI_VER5 ]
-Sections:
 Sections:
   - Name:.text
 Type:SHT_PROGBITS
Index: lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad-overflow.yaml
===
--- lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad-overflow.yaml
+++ lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad-overflow.yaml
@@ -5,7 +5,6 @@
   Type:ET_DYN
   Machine: EM_ARM
   Flags:   [ EF_ARM_SOFT_FLOAT, EF_ARM_EABI_VER5 ]
-Sections:
 Sections:
   - Name:.text
 Type:SHT_PROGBITS
Index: lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad-decoy.yaml
===
--- lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad-decoy.yaml
+++ lldb/test/API/functionalities/postmortem/minidump-new/libbreakpad-decoy.yaml
@@ -8,7 +8,6 @@
   Type:ET_DYN
   Machine: EM_ARM
   Flags:   [ EF_ARM_SOFT_FLOAT, EF_ARM_EABI_VER5 ]
-Sections:
 Sections:
   - Name:.text
 Type:SHT_PROGBITS
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D143727: [Test][lldb] Fix YAML mapping keys duplication. NFC.

2023-02-10 Thread Anton Sidorenko via Phabricator via lldb-commits
asi-sc added a comment.

Similar fixes review: D141848 
LLVM YAML parser improvement that depends on this: D140474 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143727

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


[Lldb-commits] [PATCH] D143652: [lldb][DWARFASTParserClang] Attach linkage name to ctors/dtors if missing

2023-02-10 Thread Michael Buch via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb296ddd91cb8: [lldb][DWARFASTParserClang] Attach linkage 
name to ctors/dtors if missing (authored by Michael137).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143652

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/test/API/lang/cpp/external_ctor_dtor_lookup/Makefile
  lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
  lldb/test/API/lang/cpp/external_ctor_dtor_lookup/lib.h
  lldb/test/API/lang/cpp/external_ctor_dtor_lookup/main.cpp

Index: lldb/test/API/lang/cpp/external_ctor_dtor_lookup/main.cpp
===
--- /dev/null
+++ lldb/test/API/lang/cpp/external_ctor_dtor_lookup/main.cpp
@@ -0,0 +1,13 @@
+#include "lib.h"
+
+struct Foo {};
+
+struct Bar {
+  Wrapper getWrapper() { return Wrapper(); }
+  int sinkWrapper(Wrapper) { return -1; }
+};
+
+int main() {
+  Bar b;
+  return b.sinkWrapper(b.getWrapper());
+}
Index: lldb/test/API/lang/cpp/external_ctor_dtor_lookup/lib.h
===
--- /dev/null
+++ lldb/test/API/lang/cpp/external_ctor_dtor_lookup/lib.h
@@ -0,0 +1,11 @@
+#ifndef LIB_H_IN
+#define LIB_H_IN
+
+template  class Wrapper {
+public:
+  [[gnu::abi_tag("test")]] Wrapper(){};
+
+  [[gnu::abi_tag("test")]] ~Wrapper(){};
+};
+
+#endif // _H_IN
Index: lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
===
--- /dev/null
+++ lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
@@ -0,0 +1,30 @@
+"""
+Test that we can constructors/destructors
+without a linkage name because they are
+marked DW_AT_external and the fallback
+mangled-name-guesser in LLDB doesn't account
+for ABI tags.
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class ExternalCtorDtorLookupTestCase(TestBase):
+
+def test(self):
+self.build()
+lldbutil.run_to_source_breakpoint(self, 'b\.getWrapper\(\)',
+lldb.SBFileSpec('main.cpp', False))
+
+self.expect_expr('b.sinkWrapper(b.getWrapper())', result_type='int', result_value='-1')
+self.filecheck("target module dump ast", __file__)
+# CHECK:  ClassTemplateSpecializationDecl {{.*}} class Wrapper definition
+# CHECK:   |-TemplateArgument type 'Foo'
+# CHECK:   | `-RecordType {{.*}} 'Foo'
+# CHECK:   |   `-CXXRecord {{.*}} 'Foo'
+# CHECK:   |-CXXConstructorDecl {{.*}} Wrapper 'void ()'
+# CHECK-NEXT:  | `-AsmLabelAttr {{.*}} Implicit "_ZN7WrapperI3FooEC1B4testEv"
+# CHECK-NEXT:  `-CXXDestructorDecl {{.*}} ~Wrapper 'void ()'
+# CHECK-NEXT:`-AsmLabelAttr {{.*}} Implicit "_ZN7WrapperI3FooED1B4testEv"
Index: lldb/test/API/lang/cpp/external_ctor_dtor_lookup/Makefile
===
--- /dev/null
+++ lldb/test/API/lang/cpp/external_ctor_dtor_lookup/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -888,6 +888,45 @@
   return clang::CC_C;
 }
 
+/// Given a DIE with an external definition (and thus no linkage name)
+/// find the definitions by lookup into the DWARF name index.
+/// We check the DW_AT_specification for each DIE in the index with
+/// the same name as the specified 'die' until we find one that references
+/// 'die'. Then return that linkage name. If no such DIE is found in the index,
+/// returns nullptr.
+static char const *FindLinkageName(DWARFDIE die) {
+  auto *dwarf = die.GetDWARF();
+  if (!dwarf)
+return nullptr;
+
+  ConstString func_name(die.GetName());
+  if (!func_name)
+return nullptr;
+
+  SymbolContextList sc_list;
+  Module::LookupInfo lookup_info(func_name,
+ FunctionNameType::eFunctionNameTypeMethod |
+ FunctionNameType::eFunctionNameTypeFull,
+ LanguageType::eLanguageTypeUnknown);
+  dwarf->FindFunctions(lookup_info, {}, true, sc_list);
+
+  for (auto const &sc : sc_list.SymbolContexts()) {
+if (auto *func = sc.function) {
+  auto func_die = dwarf->GetDIE(func->GetID());
+  if (!func_die.IsValid())
+continue;
+
+  auto spec_die =
+  func_die.GetAttributeValueAsReferenceDIE(DW_AT_specification);
+  if (spec_die.IsValid() && spec_die == die) {
+return func->GetMangled().GetMangledName().AsCString();
+  }
+}
+  }
+
+  ret

[Lldb-commits] [lldb] b296ddd - [lldb][DWARFASTParserClang] Attach linkage name to ctors/dtors if missing

2023-02-10 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-02-10T17:22:02Z
New Revision: b296ddd91cb8e7676b3c38ca7f6d7bdbd84eb4af

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

LOG: [lldb][DWARFASTParserClang] Attach linkage name to ctors/dtors if missing

**Summary**

This patch addresses the case where we have a `DW_AT_external`
subprogram for a constructor (and/or destructor) that doesn't carry
a `DW_AT_linkage_name` attribute. The corresponding DIE(s) that
represent the definition will have a linkage name, but if the name
contains constructs that LLDBs fallback mechanism for guessing mangled
names to resolve external symbols doesn't support (e.g., abi-tags)
then we end up failing to resolve the function call.

We address this by trying to find the linkage name before we create
the constructor/destructor decl, which will get attached using
an `AsmLabelAttr` to make symbol resolution easier.

**Testing**

* Added API test

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

Added: 
lldb/test/API/lang/cpp/external_ctor_dtor_lookup/Makefile

lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
lldb/test/API/lang/cpp/external_ctor_dtor_lookup/lib.h
lldb/test/API/lang/cpp/external_ctor_dtor_lookup/main.cpp

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

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 4429b4fcae2a..0aacfd1bb0cf 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -888,6 +888,45 @@ ConvertDWARFCallingConventionToClang(const 
ParsedDWARFTypeAttributes &attrs) {
   return clang::CC_C;
 }
 
+/// Given a DIE with an external definition (and thus no linkage name)
+/// find the definitions by lookup into the DWARF name index.
+/// We check the DW_AT_specification for each DIE in the index with
+/// the same name as the specified 'die' until we find one that references
+/// 'die'. Then return that linkage name. If no such DIE is found in the index,
+/// returns nullptr.
+static char const *FindLinkageName(DWARFDIE die) {
+  auto *dwarf = die.GetDWARF();
+  if (!dwarf)
+return nullptr;
+
+  ConstString func_name(die.GetName());
+  if (!func_name)
+return nullptr;
+
+  SymbolContextList sc_list;
+  Module::LookupInfo lookup_info(func_name,
+ FunctionNameType::eFunctionNameTypeMethod |
+ FunctionNameType::eFunctionNameTypeFull,
+ LanguageType::eLanguageTypeUnknown);
+  dwarf->FindFunctions(lookup_info, {}, true, sc_list);
+
+  for (auto const &sc : sc_list.SymbolContexts()) {
+if (auto *func = sc.function) {
+  auto func_die = dwarf->GetDIE(func->GetID());
+  if (!func_die.IsValid())
+continue;
+
+  auto spec_die =
+  func_die.GetAttributeValueAsReferenceDIE(DW_AT_specification);
+  if (spec_die.IsValid() && spec_die == die) {
+return func->GetMangled().GetMangledName().AsCString();
+  }
+}
+  }
+
+  return nullptr;
+}
+
 TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
ParsedDWARFTypeAttributes &attrs) {
   Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
@@ -1116,6 +1155,12 @@ TypeSP DWARFASTParserClang::ParseSubroutine(const 
DWARFDIE &die,
   if (attrs.accessibility == eAccessNone)
 attrs.accessibility = eAccessPublic;
 
+  // Make sure we find the linkage name here so it gets
+  // attached to the member function inside
+  // AddMethodToCXXRecordType below.
+  if (!attrs.mangled_name && attrs.storage == clang::SC_Extern)
+attrs.mangled_name = FindLinkageName(die);
+
   clang::CXXMethodDecl *cxx_method_decl =
   m_ast.AddMethodToCXXRecordType(
   class_opaque_type.GetOpaqueQualType(),

diff  --git a/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/Makefile 
b/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/Makefile
new file mode 100644
index ..8b20bcb0
--- /dev/null
+++ b/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules

diff  --git 
a/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
 
b/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
new file mode 100644
index ..027fd8e39d07
--- /dev/null
+++ 
b/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py

[Lldb-commits] [PATCH] D143698: Support Debugging TLS variable with lldb

2023-02-10 Thread Jim Ingham via Phabricator via lldb-commits
jingham added a comment.

A tiny quibble: GetThreadPointer seems like it should return a pointer to the 
thread that has this register set.  I would not guess it's a pointer to the 
Thread's local storage.  Maybe GetThreadLSPointer + a doc string saying what it 
does would clear this up?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143698

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


[Lldb-commits] [lldb] f889d6f - [lldb][Test] TestExternalCtorDtorLookup.py: skip on Windows and dwo

2023-02-10 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-02-10T18:49:55Z
New Revision: f889d6f9d05b2b1bd188ddf40b3d38a3488c212e

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

LOG: [lldb][Test] TestExternalCtorDtorLookup.py: skip on Windows and dwo

Also make expected mangling more flexible since it's different
between Linux and Darwin

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

Added: 


Modified: 

lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py

Removed: 




diff  --git 
a/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
 
b/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
index 027fd8e39d078..72015363a1794 100644
--- 
a/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
+++ 
b/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
@@ -13,6 +13,8 @@
 
 class ExternalCtorDtorLookupTestCase(TestBase):
 
+@skipIf(debug_info="dwo")
+@skipIfWindows
 def test(self):
 self.build()
 lldbutil.run_to_source_breakpoint(self, 'b\.getWrapper\(\)',
@@ -25,6 +27,6 @@ def test(self):
 # CHECK:   | `-RecordType {{.*}} 'Foo'
 # CHECK:   |   `-CXXRecord {{.*}} 'Foo'
 # CHECK:   |-CXXConstructorDecl {{.*}} Wrapper 'void ()'
-# CHECK-NEXT:  | `-AsmLabelAttr {{.*}} Implicit 
"_ZN7WrapperI3FooEC1B4testEv"
+# CHECK-NEXT:  | `-AsmLabelAttr {{.*}} Implicit 
"_ZN7WrapperI3Foo{{.*}}testEv"
 # CHECK-NEXT:  `-CXXDestructorDecl {{.*}} ~Wrapper 'void ()'
-# CHECK-NEXT:`-AsmLabelAttr {{.*}} Implicit 
"_ZN7WrapperI3FooED1B4testEv"
+# CHECK-NEXT:`-AsmLabelAttr {{.*}} Implicit 
"_ZN7WrapperI3Foo{{.*}}testEv"



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


[Lldb-commits] [PATCH] D143690: [lldb] Add the ability to provide a message to a progress event update

2023-02-10 Thread Alex Langford via Phabricator via lldb-commits
bulbazord accepted this revision.
bulbazord added a comment.

Thanks for including the motivation in your summary, that made following this 
change a lot easier.

LGTM


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

https://reviews.llvm.org/D143690

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


[Lldb-commits] [PATCH] D143772: Adapt TestCustomShell and TestMultipleDebuggers to run under ASAN

2023-02-10 Thread Augusto Noronha via Phabricator via lldb-commits
augusto2112 created this revision.
augusto2112 added reviewers: JDevlieghere, jingham, aprantl.
Herald added a project: All.
augusto2112 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

In situations where only LLDB is ASANified, a false positive occurs
unless ASAN_OPTIONS=detect_container_overflow=0 is set in the
environment.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143772

Files:
  lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
  lldb/test/Shell/Host/TestCustomShell.test


Index: lldb/test/Shell/Host/TestCustomShell.test
===
--- lldb/test/Shell/Host/TestCustomShell.test
+++ lldb/test/Shell/Host/TestCustomShell.test
@@ -7,7 +7,7 @@
 
 # RUN: %clang_host %S/Inputs/simple.c -g -o %t.out
 # RUN: SHELL=bogus not %lldb %t.out -b -o 'process launch -X 1 --' 2>&1 | 
FileCheck %s --check-prefix ERROR
-# RUN: env -i %lldb %t.out -b -o 'process launch -X 1 --' 2>&1 | FileCheck %s
+# RUN: env -i ASAN_OPTIONS='detect_container_overflow=0' %lldb %t.out -b -o 
'process launch -X 1 --' 2>&1 | FileCheck %s
 
 # ERROR: error: shell expansion failed
 # CHECK-NOT: error: shell expansion failed
Index: lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
===
--- lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
+++ lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
@@ -15,7 +15,9 @@
 @skipIfNoSBHeaders
 @skipIfWindows
 def test_multiple_debuggers(self):
-env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
+env = {self.dylibPath: self.getLLDBLibraryEnvVal(),
+  # We need this in order to run under ASAN, in case only LLDB is 
ASANified.
+  'ASAN_OPTIONS':'detect_container_overflow=0'}
 
 self.driver_exe = self.getBuildArtifact("multi-process-driver")
 self.buildDriver('multi-process-driver.cpp', self.driver_exe)


Index: lldb/test/Shell/Host/TestCustomShell.test
===
--- lldb/test/Shell/Host/TestCustomShell.test
+++ lldb/test/Shell/Host/TestCustomShell.test
@@ -7,7 +7,7 @@
 
 # RUN: %clang_host %S/Inputs/simple.c -g -o %t.out
 # RUN: SHELL=bogus not %lldb %t.out -b -o 'process launch -X 1 --' 2>&1 | FileCheck %s --check-prefix ERROR
-# RUN: env -i %lldb %t.out -b -o 'process launch -X 1 --' 2>&1 | FileCheck %s
+# RUN: env -i ASAN_OPTIONS='detect_container_overflow=0' %lldb %t.out -b -o 'process launch -X 1 --' 2>&1 | FileCheck %s
 
 # ERROR: error: shell expansion failed
 # CHECK-NOT: error: shell expansion failed
Index: lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
===
--- lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
+++ lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
@@ -15,7 +15,9 @@
 @skipIfNoSBHeaders
 @skipIfWindows
 def test_multiple_debuggers(self):
-env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
+env = {self.dylibPath: self.getLLDBLibraryEnvVal(),
+  # We need this in order to run under ASAN, in case only LLDB is ASANified.
+  'ASAN_OPTIONS':'detect_container_overflow=0'}
 
 self.driver_exe = self.getBuildArtifact("multi-process-driver")
 self.buildDriver('multi-process-driver.cpp', self.driver_exe)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D143690: [lldb] Add the ability to provide a message to a progress event update

2023-02-10 Thread Dave Lee via Phabricator via lldb-commits
kastiglione accepted this revision.
kastiglione added a comment.

nice




Comment at: lldb/include/lldb/Core/DebuggerEvents.h:48-49
+  }
+  const std::string &GetTitle() const { return m_title; }
+  const std::string &GetUpdate() const { return m_update; }
   bool IsDebuggerSpecific() const { return m_debugger_specific; }

Are these going to be needed in a follow up?



Comment at: lldb/include/lldb/Core/DebuggerEvents.h:54
+  std::string m_title;
+  std::string m_update;
   const uint64_t m_id;

minor quibble, but maybe `m_current_subtitle` (or some other 
`m_current_`) – I know that's wordy but "update" is a bit vague. Do as 
you please tho.


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

https://reviews.llvm.org/D143690

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


[Lldb-commits] [PATCH] D143772: Adapt TestCustomShell and TestMultipleDebuggers to run under ASAN

2023-02-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Why are only these two tests affected? Should this be something we set globally 
for all the tests? The API tests already have support for forwarding 
`ASAN_OPTIONS` and lit has a similar concept.

I can imagine why `TestMultipleSimultaneousDebuggers` would be special: it 
basically build its own driver (so the detest machinery to set the inferior env 
doesn't work). But I'm a little puzzled by the shell tests, especially since 
you only updated a single RUN line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143772

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


[Lldb-commits] [PATCH] D143772: Adapt TestCustomShell and TestMultipleDebuggers to run under ASAN

2023-02-10 Thread Augusto Noronha via Phabricator via lldb-commits
augusto2112 added a comment.

In D143772#4119213 , @JDevlieghere 
wrote:

> Why are only these two tests affected? Should this be something we set 
> globally for all the tests? The API tests already have support for forwarding 
> `ASAN_OPTIONS` and lit has a similar concept.

Because they both set their own environment in one way or the other, which 
doesn't happen in the usual cas.

> But I'm a little puzzled by the shell tests, especially since you only 
> updated a single RUN line.

"env -i " means only use the enviroments passed in that line (discard 
everything else).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143772

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


[Lldb-commits] [PATCH] D143687: [lldb] Add an SB API to get progress events as SBStructuredData

2023-02-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 496575.
JDevlieghere marked an inline comment as done.
JDevlieghere added a comment.

Address @mib's feedback


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

https://reviews.llvm.org/D143687

Files:
  lldb/bindings/interface/SBDebugger.i
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/Core/DebuggerEvents.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Core/DebuggerEvents.cpp
  lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py

Index: lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
===
--- lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
+++ lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
@@ -28,3 +28,14 @@
 message = ret_args[0]
 self.assertGreater(len(message), 0)
 
+def test_dwarf_symbol_loading_progress_report_structured_data(self):
+"""Test that we are able to fetch dwarf symbol loading progress events using the structured data API"""
+self.build()
+
+lldbutil.run_to_source_breakpoint(self, 'break here', lldb.SBFileSpec('main.c'))
+
+event = lldbutil.fetch_next_event(self, self.listener, self.broadcaster)
+progress_data = lldb.SBDebugger.GetProgressDataFromEvent(event)
+message = progress_data.GetValueForKey("message").GetStringValue(100)
+self.assertGreater(len(message), 0)
+
Index: lldb/source/Core/DebuggerEvents.cpp
===
--- lldb/source/Core/DebuggerEvents.cpp
+++ lldb/source/Core/DebuggerEvents.cpp
@@ -49,6 +49,25 @@
   return GetEventDataFromEventImpl(event_ptr);
 }
 
+StructuredData::DictionarySP
+ProgressEventData::GetAsStructuredData(const Event *event_ptr) {
+  const ProgressEventData *progress_data =
+  ProgressEventData::GetEventDataFromEvent(event_ptr);
+
+  if (!progress_data)
+return {};
+
+  auto dictionary_sp = std::make_shared();
+  dictionary_sp->AddStringItem("message", progress_data->GetMessage());
+  dictionary_sp->AddIntegerItem("progress_id", progress_data->GetID());
+  dictionary_sp->AddIntegerItem("completed", progress_data->GetCompleted());
+  dictionary_sp->AddIntegerItem("total", progress_data->GetTotal());
+  dictionary_sp->AddBooleanItem("debugger_specific",
+progress_data->IsDebuggerSpecific());
+
+  return dictionary_sp;
+}
+
 llvm::StringRef DiagnosticEventData::GetPrefix() const {
   switch (m_type) {
   case Type::Info:
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -168,6 +168,21 @@
   return progress_data->GetMessage().c_str();
 }
 
+lldb::SBStructuredData
+SBDebugger::GetProgressDataFromEvent(const lldb::SBEvent &event) {
+  LLDB_INSTRUMENT_VA(event);
+
+  StructuredData::DictionarySP dictionary_sp =
+  ProgressEventData::GetAsStructuredData(event.get());
+
+  if (!dictionary_sp)
+return {};
+
+  SBStructuredData data;
+  data.m_impl_up->SetObjectSP(std::move(dictionary_sp));
+  return data;
+}
+
 lldb::SBStructuredData
 SBDebugger::GetDiagnosticFromEvent(const lldb::SBEvent &event) {
   LLDB_INSTRUMENT_VA(event);
Index: lldb/include/lldb/Core/DebuggerEvents.h
===
--- lldb/include/lldb/Core/DebuggerEvents.h
+++ lldb/include/lldb/Core/DebuggerEvents.h
@@ -33,6 +33,10 @@
   void Dump(Stream *s) const override;
 
   static const ProgressEventData *GetEventDataFromEvent(const Event *event_ptr);
+
+  static StructuredData::DictionarySP
+  GetAsStructuredData(const Event *event_ptr);
+
   uint64_t GetID() const { return m_id; }
   bool IsFinite() const { return m_total != UINT64_MAX; }
   uint64_t GetCompleted() const { return m_completed; }
Index: lldb/include/lldb/API/SBDebugger.h
===
--- lldb/include/lldb/API/SBDebugger.h
+++ lldb/include/lldb/API/SBDebugger.h
@@ -83,6 +83,9 @@
   uint64_t &completed, uint64_t &total,
   bool &is_debugger_specific);
 
+  static lldb::SBStructuredData
+  GetProgressDataFromEvent(const lldb::SBEvent &event);
+
   static lldb::SBStructuredData
   GetDiagnosticFromEvent(const lldb::SBEvent &event);
 
Index: lldb/bindings/interface/SBDebugger.i
===
--- lldb/bindings/interface/SBDebugger.i
+++ lldb/bindings/interface/SBDebugger.i
@@ -131,6 +131,8 @@
 uint64_t &OUTPUT,
 bool &OUTPUT);
 
+static lldb::SBStructuredData GetProgressDataFromEvent(const lldb::SBEvent &event);
+
 static lldb::SBStructuredData GetDiagnosticFromEvent(const lldb::SBEv

[Lldb-commits] [PATCH] D143690: [lldb] Add the ability to provide a message to a progress event update

2023-02-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere marked 2 inline comments as done.
JDevlieghere added inline comments.



Comment at: lldb/include/lldb/Core/DebuggerEvents.h:48-49
+  }
+  const std::string &GetTitle() const { return m_title; }
+  const std::string &GetUpdate() const { return m_update; }
   bool IsDebuggerSpecific() const { return m_debugger_specific; }

kastiglione wrote:
> Are these going to be needed in a follow up?
Yes, they're going in the dict from D143690. I saw Ismail's comments while 
working on this patch so I knew I was going to change it. 



Comment at: lldb/include/lldb/Core/DebuggerEvents.h:54
+  std::string m_title;
+  std::string m_update;
   const uint64_t m_id;

kastiglione wrote:
> minor quibble, but maybe `m_current_subtitle` (or some other 
> `m_current_`) – I know that's wordy but "update" is a bit vague. Do as 
> you please tho.
How about `m_details`. I don't think we need to include current here, as this 
is all part of a single event. I'll add comments to set expectations about the 
title being fixed and the details potentially changing. 


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

https://reviews.llvm.org/D143690

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


[Lldb-commits] [PATCH] D143690: [lldb] Add the ability to provide a message to a progress event update

2023-02-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere updated this revision to Diff 496577.
JDevlieghere marked 2 inline comments as done.
JDevlieghere added a comment.

- update -> details
- expose title and details separately in structured data


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

https://reviews.llvm.org/D143690

Files:
  lldb/include/lldb/Core/Debugger.h
  lldb/include/lldb/Core/DebuggerEvents.h
  lldb/include/lldb/Core/Progress.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/DebuggerEvents.cpp
  lldb/source/Core/Progress.cpp

Index: lldb/source/Core/Progress.cpp
===
--- lldb/source/Core/Progress.cpp
+++ lldb/source/Core/Progress.cpp
@@ -36,7 +36,7 @@
   }
 }
 
-void Progress::Increment(uint64_t amount) {
+void Progress::Increment(uint64_t amount, std::string update) {
   if (amount > 0) {
 std::lock_guard guard(m_mutex);
 // Watch out for unsigned overflow and make sure we don't increment too
@@ -45,16 +45,16 @@
   m_completed = m_total;
 else
   m_completed += amount;
-ReportProgress();
+ReportProgress(update);
   }
 }
 
-void Progress::ReportProgress() {
+void Progress::ReportProgress(std::string update) {
   if (!m_complete) {
 // Make sure we only send one notification that indicates the progress is
 // complete.
 m_complete = m_completed == m_total;
-Debugger::ReportProgress(m_id, m_title, m_completed, m_total,
- m_debugger_id);
+Debugger::ReportProgress(m_id, m_title, std::move(update), m_completed,
+ m_total, m_debugger_id);
   }
 }
Index: lldb/source/Core/DebuggerEvents.cpp
===
--- lldb/source/Core/DebuggerEvents.cpp
+++ lldb/source/Core/DebuggerEvents.cpp
@@ -33,7 +33,9 @@
 }
 
 void ProgressEventData::Dump(Stream *s) const {
-  s->Printf(" id = %" PRIu64 ", message = \"%s\"", m_id, m_message.c_str());
+  s->Printf(" id = %" PRIu64 ", title = \"%s\"", m_id, m_title.c_str());
+  if (!m_details.empty())
+s->Printf(", details = \"%s\"", m_details.c_str());
   if (m_completed == 0 || m_completed == m_total)
 s->Printf(", type = %s", m_completed == 0 ? "start" : "end");
   else
@@ -58,6 +60,8 @@
 return {};
 
   auto dictionary_sp = std::make_shared();
+  dictionary_sp->AddStringItem("title", progress_data->GetTitle());
+  dictionary_sp->AddStringItem("details", progress_data->GetDetails());
   dictionary_sp->AddStringItem("message", progress_data->GetMessage());
   dictionary_sp->AddIntegerItem("progress_id", progress_data->GetID());
   dictionary_sp->AddIntegerItem("completed", progress_data->GetCompleted());
Index: lldb/source/Core/Debugger.cpp
===
--- lldb/source/Core/Debugger.cpp
+++ lldb/source/Core/Debugger.cpp
@@ -1286,7 +1286,7 @@
 }
 
 static void PrivateReportProgress(Debugger &debugger, uint64_t progress_id,
-  const std::string &message,
+  std::string title, std::string details,
   uint64_t completed, uint64_t total,
   bool is_debugger_specific) {
   // Only deliver progress events if we have any progress listeners.
@@ -1294,13 +1294,15 @@
   if (!debugger.GetBroadcaster().EventTypeHasListeners(event_type))
 return;
   EventSP event_sp(new Event(
-  event_type, new ProgressEventData(progress_id, message, completed, total,
-is_debugger_specific)));
+  event_type,
+  new ProgressEventData(progress_id, std::move(title), std::move(details),
+completed, total, is_debugger_specific)));
   debugger.GetBroadcaster().BroadcastEvent(event_sp);
 }
 
-void Debugger::ReportProgress(uint64_t progress_id, const std::string &message,
-  uint64_t completed, uint64_t total,
+void Debugger::ReportProgress(uint64_t progress_id, std::string title,
+  std::string details, uint64_t completed,
+  uint64_t total,
   std::optional debugger_id) {
   // Check if this progress is for a specific debugger.
   if (debugger_id) {
@@ -1308,8 +1310,9 @@
 // still exists.
 DebuggerSP debugger_sp = FindDebuggerWithID(*debugger_id);
 if (debugger_sp)
-  PrivateReportProgress(*debugger_sp, progress_id, message, completed,
-total, /*is_debugger_specific*/ true);
+  PrivateReportProgress(*debugger_sp, progress_id, std::move(title),
+std::move(details), completed, total,
+/*is_debugger_specific*/ true);
 return;
   }
   // The progress event is not debugger specific, iterate over all debuggers
@@ -1318,8 +1321,8 @@
 std::lock_guard guard(*g_debugger_list_mutex_ptr);

[Lldb-commits] [PATCH] D143772: Adapt TestCustomShell and TestMultipleDebuggers to run under ASAN

2023-02-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

Generally LGTM, with one possible improvement inline!




Comment at: lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py:20
+  # We need this in order to run under ASAN, in case only LLDB is 
ASANified.
+  'ASAN_OPTIONS':'detect_container_overflow=0'}
 

IIUC, the python process executing this python code should already have this 
flag passed in via lit, so if it's possible to say something like  
`'ASAN_OPTIONS':getEnv('ASAN_OPTIONS'` then that would be the cleanest 
implementation.



Comment at: lldb/test/Shell/Host/TestCustomShell.test:10
 # RUN: SHELL=bogus not %lldb %t.out -b -o 'process launch -X 1 --' 2>&1 | 
FileCheck %s --check-prefix ERROR
-# RUN: env -i %lldb %t.out -b -o 'process launch -X 1 --' 2>&1 | FileCheck %s
+# RUN: env -i ASAN_OPTIONS='detect_container_overflow=0' %lldb %t.out -b -o 
'process launch -X 1 --' 2>&1 | FileCheck %s
 

This is as good as we can do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143772

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


[Lldb-commits] [PATCH] D143772: Adapt TestCustomShell and TestMultipleDebuggers to run under ASAN

2023-02-10 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added a comment.

> Why are only these two tests affected? Should this be something we set 
> globally for all the tests? The API tests already have support for forwarding 
> ASAN_OPTIONS and lit has a similar concept.

We do, but only for dotest tests, and our dotest test launches another LLDB.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143772

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


[Lldb-commits] [PATCH] D143772: Adapt TestCustomShell and TestMultipleDebuggers to run under ASAN

2023-02-10 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.

In D143772#4119227 , @augusto2112 
wrote:

> "env -i " means only use the enviroments passed in that line (discard 
> everything else).

Thanks, I didn't notice `-i`.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143772

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


[Lldb-commits] [PATCH] D143652: [lldb][DWARFASTParserClang] Attach linkage name to ctors/dtors if missing

2023-02-10 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added a comment.

This seems to cause many lldb failures 
https://lab.llvm.org/buildbot/#/builders/68/builds/47790


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143652

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


[Lldb-commits] [PATCH] D143652: [lldb][DWARFASTParserClang] Attach linkage name to ctors/dtors if missing

2023-02-10 Thread Michael Buch via Phabricator via lldb-commits
Michael137 added a comment.

In D143652#4119484 , @MaskRay wrote:

> This seems to cause many lldb failures 
> https://lab.llvm.org/buildbot/#/builders/68/builds/47790

Argh thanks for reporting, let me revert for now and try on my linux machine


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143652

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


[Lldb-commits] [lldb] c46e15e - Revert "[lldb][Test] TestExternalCtorDtorLookup.py: skip on Windows and dwo"

2023-02-10 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-02-10T23:02:50Z
New Revision: c46e15e1dec9bb504f8a534b001cea553c7ab623

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

LOG: Revert "[lldb][Test] TestExternalCtorDtorLookup.py: skip on Windows and 
dwo"

This reverts commit f889d6f9d05b2b1bd188ddf40b3d38a3488c212e.

Added: 


Modified: 

lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py

Removed: 




diff  --git 
a/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
 
b/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
index 72015363a1794..027fd8e39d078 100644
--- 
a/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
+++ 
b/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
@@ -13,8 +13,6 @@
 
 class ExternalCtorDtorLookupTestCase(TestBase):
 
-@skipIf(debug_info="dwo")
-@skipIfWindows
 def test(self):
 self.build()
 lldbutil.run_to_source_breakpoint(self, 'b\.getWrapper\(\)',
@@ -27,6 +25,6 @@ def test(self):
 # CHECK:   | `-RecordType {{.*}} 'Foo'
 # CHECK:   |   `-CXXRecord {{.*}} 'Foo'
 # CHECK:   |-CXXConstructorDecl {{.*}} Wrapper 'void ()'
-# CHECK-NEXT:  | `-AsmLabelAttr {{.*}} Implicit 
"_ZN7WrapperI3Foo{{.*}}testEv"
+# CHECK-NEXT:  | `-AsmLabelAttr {{.*}} Implicit 
"_ZN7WrapperI3FooEC1B4testEv"
 # CHECK-NEXT:  `-CXXDestructorDecl {{.*}} ~Wrapper 'void ()'
-# CHECK-NEXT:`-AsmLabelAttr {{.*}} Implicit 
"_ZN7WrapperI3Foo{{.*}}testEv"
+# CHECK-NEXT:`-AsmLabelAttr {{.*}} Implicit 
"_ZN7WrapperI3FooED1B4testEv"



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


[Lldb-commits] [lldb] d2cc2c5 - Revert "[lldb][DWARFASTParserClang] Attach linkage name to ctors/dtors if missing"

2023-02-10 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2023-02-10T23:02:57Z
New Revision: d2cc2c5610ffa78736aa99512bc85a85417efb0a

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

LOG: Revert "[lldb][DWARFASTParserClang] Attach linkage name to ctors/dtors if 
missing"

This reverts commit b296ddd91cb8e7676b3c38ca7f6d7bdbd84eb4af.

Added: 


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

Removed: 
lldb/test/API/lang/cpp/external_ctor_dtor_lookup/Makefile

lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
lldb/test/API/lang/cpp/external_ctor_dtor_lookup/lib.h
lldb/test/API/lang/cpp/external_ctor_dtor_lookup/main.cpp



diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 0aacfd1bb0cf8..4429b4fcae2a0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -888,45 +888,6 @@ ConvertDWARFCallingConventionToClang(const 
ParsedDWARFTypeAttributes &attrs) {
   return clang::CC_C;
 }
 
-/// Given a DIE with an external definition (and thus no linkage name)
-/// find the definitions by lookup into the DWARF name index.
-/// We check the DW_AT_specification for each DIE in the index with
-/// the same name as the specified 'die' until we find one that references
-/// 'die'. Then return that linkage name. If no such DIE is found in the index,
-/// returns nullptr.
-static char const *FindLinkageName(DWARFDIE die) {
-  auto *dwarf = die.GetDWARF();
-  if (!dwarf)
-return nullptr;
-
-  ConstString func_name(die.GetName());
-  if (!func_name)
-return nullptr;
-
-  SymbolContextList sc_list;
-  Module::LookupInfo lookup_info(func_name,
- FunctionNameType::eFunctionNameTypeMethod |
- FunctionNameType::eFunctionNameTypeFull,
- LanguageType::eLanguageTypeUnknown);
-  dwarf->FindFunctions(lookup_info, {}, true, sc_list);
-
-  for (auto const &sc : sc_list.SymbolContexts()) {
-if (auto *func = sc.function) {
-  auto func_die = dwarf->GetDIE(func->GetID());
-  if (!func_die.IsValid())
-continue;
-
-  auto spec_die =
-  func_die.GetAttributeValueAsReferenceDIE(DW_AT_specification);
-  if (spec_die.IsValid() && spec_die == die) {
-return func->GetMangled().GetMangledName().AsCString();
-  }
-}
-  }
-
-  return nullptr;
-}
-
 TypeSP DWARFASTParserClang::ParseSubroutine(const DWARFDIE &die,
ParsedDWARFTypeAttributes &attrs) {
   Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
@@ -1155,12 +1116,6 @@ TypeSP DWARFASTParserClang::ParseSubroutine(const 
DWARFDIE &die,
   if (attrs.accessibility == eAccessNone)
 attrs.accessibility = eAccessPublic;
 
-  // Make sure we find the linkage name here so it gets
-  // attached to the member function inside
-  // AddMethodToCXXRecordType below.
-  if (!attrs.mangled_name && attrs.storage == clang::SC_Extern)
-attrs.mangled_name = FindLinkageName(die);
-
   clang::CXXMethodDecl *cxx_method_decl =
   m_ast.AddMethodToCXXRecordType(
   class_opaque_type.GetOpaqueQualType(),

diff  --git a/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/Makefile 
b/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/Makefile
deleted file mode 100644
index 8b20bcb05..0
--- a/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-CXX_SOURCES := main.cpp
-
-include Makefile.rules

diff  --git 
a/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
 
b/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
deleted file mode 100644
index 027fd8e39d078..0
--- 
a/lldb/test/API/lang/cpp/external_ctor_dtor_lookup/TestExternalCtorDtorLookup.py
+++ /dev/null
@@ -1,30 +0,0 @@
-"""
-Test that we can constructors/destructors
-without a linkage name because they are
-marked DW_AT_external and the fallback
-mangled-name-guesser in LLDB doesn't account
-for ABI tags.
-"""
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-class ExternalCtorDtorLookupTestCase(TestBase):
-
-def test(self):
-self.build()
-lldbutil.run_to_source_breakpoint(self, 'b\.getWrapper\(\)',
-lldb.SBFileSpec('main.cpp', False))
-
-self.expect_expr('b.sinkWrapper(b.getWrapper())', result_type='int', 
result_

[Lldb-commits] [PATCH] D143501: [clang][DebugInfo] lldb: Use preferred name's type when emitting DW_AT_names

2023-02-10 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a subscriber: probinson.
dblaikie added a comment.

In D143501#4116200 , @Michael137 
wrote:

>> I'd recommend a possible long-term solution would be simplified template 
>> names (so we don't have to worry about encoding this in the `DW_AT_name` 
>> anyway) and a "DW_AT_LLVM_preferred_name" or similar attribute on a type 
>> that refers to the typedef that is the preferred name. This would generalize 
>> further than only appearing in template names - the type of a variable 
>> inside a template would also gain the beneficial naming (eg: 
>> `template void f1(T t) { }` - as it stands, the type of the 
>> variable `t` must be `std::basic_string> `DW_TAG_class_type` for `std::basic_string> attribute on it, then a debugger could helpfully render the type by its 
>> preferred alias instead)
>
> That could be a neat solution. I probably asked this before, but what's the 
> timeline with switching it on by default (if such plan is in the works at 
> all)?

I haven't especially planned that - though given it's been picked up by Fuschia 
and Chromium (at least in some build modes), and we got gdb and lldb mostly 
fixed, maybe it's worth considering. Defaulting on for lldb might be easier 
than for gdb (gdb has some outstanding index bugs with it). But generally I 
figure you Apple folks tend to be the ones who have more investment in what the 
lldb tuning should cover, or not?

If you folks want to try turning it on & we could see about turning it on by 
default for lldb tuning?

>> Alternatively, I suppose, the DWARF emission could just look at the 
>> preferred name and use that as the `DW_AT_type` in all cases anyway? Avoids 
>> needing a new attribute, etc, though would be a bit quirky in its own way.
>
> This is how I first thought of implementing it, but ran into some circular 
> dependency quirks and started working on this patch instead. Could take a 
> second stab at doing so if that's the preference. Would be nice to not have 
> this behind a tuning

yeah, happy to help with pointers, etc.

I think /maybe/ we had some design principle that DWARF features wouldn't be 
solely controlled by debugger tuning, the tuning only indicates defaults but 
tehy can be controlled by flags? Not sure if I'm remembering that quite right, 
though - maybe @probinson remembers more of that?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143501

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


[Lldb-commits] [PATCH] D143792: [lldb] Fix image lookup crash

2023-02-10 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, mib, jingham.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

lldb may crash when performing `image lookup --verbose --address $ADDR`.
The ExecutionContext that gets passed into DWARFExpression::Evaluate may
be valid but unpopulated. However, in one specific case, we were
assuming that it has a valid Target and using it without checking first.

We reach this codepath when we attempt to get information about an
address that doesn't map to a CompileUnit in the module containing the
requested address. lldb then checks to see if it maps to a global
variable, so lldb has to evaluate the location of each global variable
in the module. If a location expression contains DW_OP_deref_size that
uses a FileAddress, we hit this code path. The simplest test case is to
take a module that has a global variable with DW_OP_deref_size in its
location expression, attempt to read an address that doesn't map to a
CompileUnit (e.g. 0x0) and ensure we don't crash.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143792

Files:
  lldb/source/Expression/DWARFExpression.cpp
  lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_deref_size_static_var.s


Index: lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_deref_size_static_var.s
===
--- lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_deref_size_static_var.s
+++ lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_deref_size_static_var.s
@@ -1,11 +1,17 @@
 # RUN: llvm-mc -filetype=obj -o %t -triple x86_64-apple-macosx10.15.0 %s
-# RUN: %lldb %t -o "target variable ug" -b | FileCheck %s
+# RUN: %lldb %t -o "target variable ug" -b \
+# RUN:  | FileCheck --check-prefix=TARGET-VARIABLE %s
+# RUN: %lldb %t -o "image lookup --verbose --address 0x0" -b \
+# RUN:  | FileCheck --check-prefix=IMAGE-LOOKUP %s
 
-# CHECK: (lldb) target variable ug
-# CHECK: (U) ug = {
-# CHECK:   raw = 0
-# CHECK:= (a = 0, b = 0, c = 0, d = 0, e = 0, f = 0)
-# CHECK: }
+# TARGET-VARIABLE: (lldb) target variable ug
+# TARGET-VARIABLE: (U) ug = {
+# TARGET-VARIABLE:   raw = 0
+# TARGET-VARIABLE:= (a = 0, b = 0, c = 0, d = 0, e = 0, f = 0)
+# TARGET-VARIABLE: }
+
+# IMAGE-LOOKUP: Summary:
+# IMAGE-LOOKUP: Module: file =
 
 # We are testing how DWARFExpression::Evaluate(...) in the case of
 # DW_OP_deref_size deals with static variable.
Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -1140,9 +1140,9 @@
   uint8_t addr_bytes[8];
   Status error;
 
-  if (exe_ctx->GetTargetRef().ReadMemory(
-  so_addr, &addr_bytes, size, error,
-  /*force_live_memory=*/false) == size) {
+  if (target &&
+  target->ReadMemory(so_addr, &addr_bytes, size, error,
+ /*force_live_memory=*/false) == size) {
 ObjectFile *objfile = module_sp->GetObjectFile();
 
 stack.back().GetScalar() = DerefSizeExtractDataHelper(


Index: lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_deref_size_static_var.s
===
--- lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_deref_size_static_var.s
+++ lldb/test/Shell/SymbolFile/DWARF/x86/DW_OP_deref_size_static_var.s
@@ -1,11 +1,17 @@
 # RUN: llvm-mc -filetype=obj -o %t -triple x86_64-apple-macosx10.15.0 %s
-# RUN: %lldb %t -o "target variable ug" -b | FileCheck %s
+# RUN: %lldb %t -o "target variable ug" -b \
+# RUN:  | FileCheck --check-prefix=TARGET-VARIABLE %s
+# RUN: %lldb %t -o "image lookup --verbose --address 0x0" -b \
+# RUN:  | FileCheck --check-prefix=IMAGE-LOOKUP %s
 
-# CHECK: (lldb) target variable ug
-# CHECK: (U) ug = {
-# CHECK:   raw = 0
-# CHECK:= (a = 0, b = 0, c = 0, d = 0, e = 0, f = 0)
-# CHECK: }
+# TARGET-VARIABLE: (lldb) target variable ug
+# TARGET-VARIABLE: (U) ug = {
+# TARGET-VARIABLE:   raw = 0
+# TARGET-VARIABLE:= (a = 0, b = 0, c = 0, d = 0, e = 0, f = 0)
+# TARGET-VARIABLE: }
+
+# IMAGE-LOOKUP: Summary:
+# IMAGE-LOOKUP: Module: file =
 
 # We are testing how DWARFExpression::Evaluate(...) in the case of
 # DW_OP_deref_size deals with static variable.
Index: lldb/source/Expression/DWARFExpression.cpp
===
--- lldb/source/Expression/DWARFExpression.cpp
+++ lldb/source/Expression/DWARFExpression.cpp
@@ -1140,9 +1140,9 @@
   uint8_t addr_bytes[8];
   Status error;
 
-  if (exe_ctx->GetTargetRef().ReadMemory(
-  so_addr, &addr_bytes, size, error,
-  /*force_live_memory=*/false) == size) {
+  if (target &&
+  target->ReadMemory(so_addr, &addr_bytes, size, error,
+  

[Lldb-commits] [PATCH] D143792: [lldb] Fix image lookup crash

2023-02-10 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib accepted this revision.
mib added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143792

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


[Lldb-commits] [PATCH] D143687: [lldb] Add an SB API to get progress events as SBStructuredData

2023-02-10 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib accepted this revision.
mib added a comment.
This revision is now accepted and ready to land.

Thanks! LGTM!


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

https://reviews.llvm.org/D143687

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


[Lldb-commits] [PATCH] D135631: [lldb] Copy log files into diagnostic directory

2023-02-10 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib accepted this revision.
mib added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: lldb/source/Core/Debugger.cpp:838
+std::error_code ec =
+llvm::sys::fs::copy_file(entry.first(), destination.GetPath());
+if (ec)

re-use `log_path` for more clarity


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

https://reviews.llvm.org/D135631

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


[Lldb-commits] [lldb] 0ac8dfd - [lldb] Add an SB API to get progress events as SBStructuredData

2023-02-10 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-02-10T17:18:00-08:00
New Revision: 0ac8dfd0587a1a95e8ed464bc59741837aae9c1f

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

LOG: [lldb] Add an SB API to get progress events as SBStructuredData

This is a preparatory patch to add an SB API to get the progress data as
SBStructuredData. The advantage of using SBStructuredData is that the
dictionary can grow over time with more fields.

This approach is identical to the way this is implemented for diagnostic
events.

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

Added: 


Modified: 
lldb/bindings/interface/SBDebugger.i
lldb/include/lldb/API/SBDebugger.h
lldb/include/lldb/Core/DebuggerEvents.h
lldb/source/API/SBDebugger.cpp
lldb/source/Core/DebuggerEvents.cpp
lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py

Removed: 




diff  --git a/lldb/bindings/interface/SBDebugger.i 
b/lldb/bindings/interface/SBDebugger.i
index e82ce2aa8e7c..7132902275ff 100644
--- a/lldb/bindings/interface/SBDebugger.i
+++ b/lldb/bindings/interface/SBDebugger.i
@@ -131,6 +131,8 @@ public:
 uint64_t &OUTPUT,
 bool &OUTPUT);
 
+static lldb::SBStructuredData GetProgressDataFromEvent(const lldb::SBEvent 
&event);
+
 static lldb::SBStructuredData GetDiagnosticFromEvent(const lldb::SBEvent 
&event);
 
 SBBroadcaster GetBroadcaster();

diff  --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 950e8e29ef79..0aee6b7dbddf 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -83,6 +83,9 @@ class LLDB_API SBDebugger {
   uint64_t &completed, uint64_t &total,
   bool &is_debugger_specific);
 
+  static lldb::SBStructuredData
+  GetProgressDataFromEvent(const lldb::SBEvent &event);
+
   static lldb::SBStructuredData
   GetDiagnosticFromEvent(const lldb::SBEvent &event);
 

diff  --git a/lldb/include/lldb/Core/DebuggerEvents.h 
b/lldb/include/lldb/Core/DebuggerEvents.h
index 7d22574aa03e..0dade0f9629a 100644
--- a/lldb/include/lldb/Core/DebuggerEvents.h
+++ b/lldb/include/lldb/Core/DebuggerEvents.h
@@ -33,6 +33,10 @@ class ProgressEventData : public EventData {
   void Dump(Stream *s) const override;
 
   static const ProgressEventData *GetEventDataFromEvent(const Event 
*event_ptr);
+
+  static StructuredData::DictionarySP
+  GetAsStructuredData(const Event *event_ptr);
+
   uint64_t GetID() const { return m_id; }
   bool IsFinite() const { return m_total != UINT64_MAX; }
   uint64_t GetCompleted() const { return m_completed; }

diff  --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index be86078c7203..2fa93e47a44c 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -168,6 +168,21 @@ const char *SBDebugger::GetProgressFromEvent(const 
lldb::SBEvent &event,
   return progress_data->GetMessage().c_str();
 }
 
+lldb::SBStructuredData
+SBDebugger::GetProgressDataFromEvent(const lldb::SBEvent &event) {
+  LLDB_INSTRUMENT_VA(event);
+
+  StructuredData::DictionarySP dictionary_sp =
+  ProgressEventData::GetAsStructuredData(event.get());
+
+  if (!dictionary_sp)
+return {};
+
+  SBStructuredData data;
+  data.m_impl_up->SetObjectSP(std::move(dictionary_sp));
+  return data;
+}
+
 lldb::SBStructuredData
 SBDebugger::GetDiagnosticFromEvent(const lldb::SBEvent &event) {
   LLDB_INSTRUMENT_VA(event);

diff  --git a/lldb/source/Core/DebuggerEvents.cpp 
b/lldb/source/Core/DebuggerEvents.cpp
index 6e47da7abd2c..fd459f899aba 100644
--- a/lldb/source/Core/DebuggerEvents.cpp
+++ b/lldb/source/Core/DebuggerEvents.cpp
@@ -49,6 +49,25 @@ ProgressEventData::GetEventDataFromEvent(const Event 
*event_ptr) {
   return GetEventDataFromEventImpl(event_ptr);
 }
 
+StructuredData::DictionarySP
+ProgressEventData::GetAsStructuredData(const Event *event_ptr) {
+  const ProgressEventData *progress_data =
+  ProgressEventData::GetEventDataFromEvent(event_ptr);
+
+  if (!progress_data)
+return {};
+
+  auto dictionary_sp = std::make_shared();
+  dictionary_sp->AddStringItem("message", progress_data->GetMessage());
+  dictionary_sp->AddIntegerItem("progress_id", progress_data->GetID());
+  dictionary_sp->AddIntegerItem("completed", progress_data->GetCompleted());
+  dictionary_sp->AddIntegerItem("total", progress_data->GetTotal());
+  dictionary_sp->AddBooleanItem("debugger_specific",
+progress_data->IsDebuggerSpecific());
+
+  return dictionary_sp;
+}
+
 llvm::StringRef DiagnosticEventData::GetPrefix() const {
   switch (m_type) {
   case Type::Info:

diff  --git 
a/lld

[Lldb-commits] [PATCH] D143687: [lldb] Add an SB API to get progress events as SBStructuredData

2023-02-10 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0ac8dfd0587a: [lldb] Add an SB API to get progress events as 
SBStructuredData (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D143687?vs=496575&id=496642#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143687

Files:
  lldb/bindings/interface/SBDebugger.i
  lldb/include/lldb/API/SBDebugger.h
  lldb/include/lldb/Core/DebuggerEvents.h
  lldb/source/API/SBDebugger.cpp
  lldb/source/Core/DebuggerEvents.cpp
  lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py

Index: lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
===
--- lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
+++ lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
@@ -28,3 +28,14 @@
 message = ret_args[0]
 self.assertGreater(len(message), 0)
 
+def test_dwarf_symbol_loading_progress_report_structured_data(self):
+"""Test that we are able to fetch dwarf symbol loading progress events
+   using the structured data API"""
+self.build()
+
+lldbutil.run_to_source_breakpoint(self, 'break here', lldb.SBFileSpec('main.c'))
+
+event = lldbutil.fetch_next_event(self, self.listener, self.broadcaster)
+progress_data = lldb.SBDebugger.GetProgressDataFromEvent(event)
+message = progress_data.GetValueForKey("message").GetStringValue(100)
+self.assertGreater(len(message), 0)
Index: lldb/source/Core/DebuggerEvents.cpp
===
--- lldb/source/Core/DebuggerEvents.cpp
+++ lldb/source/Core/DebuggerEvents.cpp
@@ -49,6 +49,25 @@
   return GetEventDataFromEventImpl(event_ptr);
 }
 
+StructuredData::DictionarySP
+ProgressEventData::GetAsStructuredData(const Event *event_ptr) {
+  const ProgressEventData *progress_data =
+  ProgressEventData::GetEventDataFromEvent(event_ptr);
+
+  if (!progress_data)
+return {};
+
+  auto dictionary_sp = std::make_shared();
+  dictionary_sp->AddStringItem("message", progress_data->GetMessage());
+  dictionary_sp->AddIntegerItem("progress_id", progress_data->GetID());
+  dictionary_sp->AddIntegerItem("completed", progress_data->GetCompleted());
+  dictionary_sp->AddIntegerItem("total", progress_data->GetTotal());
+  dictionary_sp->AddBooleanItem("debugger_specific",
+progress_data->IsDebuggerSpecific());
+
+  return dictionary_sp;
+}
+
 llvm::StringRef DiagnosticEventData::GetPrefix() const {
   switch (m_type) {
   case Type::Info:
Index: lldb/source/API/SBDebugger.cpp
===
--- lldb/source/API/SBDebugger.cpp
+++ lldb/source/API/SBDebugger.cpp
@@ -168,6 +168,21 @@
   return progress_data->GetMessage().c_str();
 }
 
+lldb::SBStructuredData
+SBDebugger::GetProgressDataFromEvent(const lldb::SBEvent &event) {
+  LLDB_INSTRUMENT_VA(event);
+
+  StructuredData::DictionarySP dictionary_sp =
+  ProgressEventData::GetAsStructuredData(event.get());
+
+  if (!dictionary_sp)
+return {};
+
+  SBStructuredData data;
+  data.m_impl_up->SetObjectSP(std::move(dictionary_sp));
+  return data;
+}
+
 lldb::SBStructuredData
 SBDebugger::GetDiagnosticFromEvent(const lldb::SBEvent &event) {
   LLDB_INSTRUMENT_VA(event);
Index: lldb/include/lldb/Core/DebuggerEvents.h
===
--- lldb/include/lldb/Core/DebuggerEvents.h
+++ lldb/include/lldb/Core/DebuggerEvents.h
@@ -33,6 +33,10 @@
   void Dump(Stream *s) const override;
 
   static const ProgressEventData *GetEventDataFromEvent(const Event *event_ptr);
+
+  static StructuredData::DictionarySP
+  GetAsStructuredData(const Event *event_ptr);
+
   uint64_t GetID() const { return m_id; }
   bool IsFinite() const { return m_total != UINT64_MAX; }
   uint64_t GetCompleted() const { return m_completed; }
Index: lldb/include/lldb/API/SBDebugger.h
===
--- lldb/include/lldb/API/SBDebugger.h
+++ lldb/include/lldb/API/SBDebugger.h
@@ -83,6 +83,9 @@
   uint64_t &completed, uint64_t &total,
   bool &is_debugger_specific);
 
+  static lldb::SBStructuredData
+  GetProgressDataFromEvent(const lldb::SBEvent &event);
+
   static lldb::SBStructuredData
   GetDiagnosticFromEvent(const lldb::SBEvent &event);
 
Index: lldb/bindings/interface/SBDebugger.i
===
--- lldb/bindings/interface/SBDebugger.i
+++ lldb/bindings/interface/SBDebugger.i
@@ -131,6 +131,8 @@
 uint64_t &OUTPUT,
 

[Lldb-commits] [PATCH] D142926: [lldb] Replace SB swig interfaces with API headers

2023-02-10 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added a comment.

Does anybody have any further concerns or objections? I'd like to get this 
change in early next week if possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142926

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


[Lldb-commits] [lldb] 294ca12 - Adapt TestCustomShell and TestMultipleDebuggers to run under ASAN

2023-02-10 Thread Augusto Noronha via lldb-commits

Author: Augusto Noronha
Date: 2023-02-10T17:19:21-08:00
New Revision: 294ca122956f78aef3ab4e81108b69518e353b07

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

LOG: Adapt TestCustomShell and TestMultipleDebuggers to run under ASAN

In situations where only LLDB is ASANified, a false positive occurs
unless ASAN_OPTIONS=detect_container_overflow=0 is set in the
environment.

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

Added: 


Modified: 
lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
lldb/test/Shell/Host/TestCustomShell.test

Removed: 




diff  --git a/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py 
b/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
index da7445f27eac..07e668c5115e 100644
--- a/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
+++ b/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
@@ -15,7 +15,9 @@ class TestMultipleSimultaneousDebuggers(TestBase):
 @skipIfNoSBHeaders
 @skipIfWindows
 def test_multiple_debuggers(self):
-env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
+env = {self.dylibPath: self.getLLDBLibraryEnvVal(),
+  # We need this in order to run under ASAN, in case only LLDB is 
ASANified.
+  'ASAN_OPTIONS': os.getenv('ASAN_OPTIONS', None)}
 
 self.driver_exe = self.getBuildArtifact("multi-process-driver")
 self.buildDriver('multi-process-driver.cpp', self.driver_exe)

diff  --git a/lldb/test/Shell/Host/TestCustomShell.test 
b/lldb/test/Shell/Host/TestCustomShell.test
index 61094ec67bc2..0e948a1b1f7f 100644
--- a/lldb/test/Shell/Host/TestCustomShell.test
+++ b/lldb/test/Shell/Host/TestCustomShell.test
@@ -7,7 +7,7 @@
 
 # RUN: %clang_host %S/Inputs/simple.c -g -o %t.out
 # RUN: SHELL=bogus not %lldb %t.out -b -o 'process launch -X 1 --' 2>&1 | 
FileCheck %s --check-prefix ERROR
-# RUN: env -i %lldb %t.out -b -o 'process launch -X 1 --' 2>&1 | FileCheck %s
+# RUN: env -i ASAN_OPTIONS='detect_container_overflow=0' %lldb %t.out -b -o 
'process launch -X 1 --' 2>&1 | FileCheck %s
 
 # ERROR: error: shell expansion failed
 # CHECK-NOT: error: shell expansion failed



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


[Lldb-commits] [PATCH] D143772: Adapt TestCustomShell and TestMultipleDebuggers to run under ASAN

2023-02-10 Thread Augusto Noronha via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG294ca122956f: Adapt TestCustomShell and 
TestMultipleDebuggers to run under ASAN (authored by augusto2112).

Changed prior to commit:
  https://reviews.llvm.org/D143772?vs=496567&id=496643#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143772

Files:
  lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
  lldb/test/Shell/Host/TestCustomShell.test


Index: lldb/test/Shell/Host/TestCustomShell.test
===
--- lldb/test/Shell/Host/TestCustomShell.test
+++ lldb/test/Shell/Host/TestCustomShell.test
@@ -7,7 +7,7 @@
 
 # RUN: %clang_host %S/Inputs/simple.c -g -o %t.out
 # RUN: SHELL=bogus not %lldb %t.out -b -o 'process launch -X 1 --' 2>&1 | 
FileCheck %s --check-prefix ERROR
-# RUN: env -i %lldb %t.out -b -o 'process launch -X 1 --' 2>&1 | FileCheck %s
+# RUN: env -i ASAN_OPTIONS='detect_container_overflow=0' %lldb %t.out -b -o 
'process launch -X 1 --' 2>&1 | FileCheck %s
 
 # ERROR: error: shell expansion failed
 # CHECK-NOT: error: shell expansion failed
Index: lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
===
--- lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
+++ lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
@@ -15,7 +15,9 @@
 @skipIfNoSBHeaders
 @skipIfWindows
 def test_multiple_debuggers(self):
-env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
+env = {self.dylibPath: self.getLLDBLibraryEnvVal(),
+  # We need this in order to run under ASAN, in case only LLDB is 
ASANified.
+  'ASAN_OPTIONS': os.getenv('ASAN_OPTIONS', None)}
 
 self.driver_exe = self.getBuildArtifact("multi-process-driver")
 self.buildDriver('multi-process-driver.cpp', self.driver_exe)


Index: lldb/test/Shell/Host/TestCustomShell.test
===
--- lldb/test/Shell/Host/TestCustomShell.test
+++ lldb/test/Shell/Host/TestCustomShell.test
@@ -7,7 +7,7 @@
 
 # RUN: %clang_host %S/Inputs/simple.c -g -o %t.out
 # RUN: SHELL=bogus not %lldb %t.out -b -o 'process launch -X 1 --' 2>&1 | FileCheck %s --check-prefix ERROR
-# RUN: env -i %lldb %t.out -b -o 'process launch -X 1 --' 2>&1 | FileCheck %s
+# RUN: env -i ASAN_OPTIONS='detect_container_overflow=0' %lldb %t.out -b -o 'process launch -X 1 --' 2>&1 | FileCheck %s
 
 # ERROR: error: shell expansion failed
 # CHECK-NOT: error: shell expansion failed
Index: lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
===
--- lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
+++ lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
@@ -15,7 +15,9 @@
 @skipIfNoSBHeaders
 @skipIfWindows
 def test_multiple_debuggers(self):
-env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
+env = {self.dylibPath: self.getLLDBLibraryEnvVal(),
+  # We need this in order to run under ASAN, in case only LLDB is ASANified.
+  'ASAN_OPTIONS': os.getenv('ASAN_OPTIONS', None)}
 
 self.driver_exe = self.getBuildArtifact("multi-process-driver")
 self.buildDriver('multi-process-driver.cpp', self.driver_exe)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 29fa21e - [lldb] Fix passing None as an env variable in TestMultipleDebuggers

2023-02-10 Thread Augusto Noronha via lldb-commits

Author: Augusto Noronha
Date: 2023-02-10T17:32:48-08:00
New Revision: 29fa21eb61293e677a8de4bacd843ef57192b60b

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

LOG: [lldb] Fix passing None as an env variable in TestMultipleDebuggers

Added: 


Modified: 
lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py

Removed: 




diff  --git a/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py 
b/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
index 07e668c5115e..64ee1a682307 100644
--- a/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
+++ b/lldb/test/API/api/multiple-debuggers/TestMultipleDebuggers.py
@@ -15,9 +15,12 @@ class TestMultipleSimultaneousDebuggers(TestBase):
 @skipIfNoSBHeaders
 @skipIfWindows
 def test_multiple_debuggers(self):
-env = {self.dylibPath: self.getLLDBLibraryEnvVal(),
-  # We need this in order to run under ASAN, in case only LLDB is 
ASANified.
-  'ASAN_OPTIONS': os.getenv('ASAN_OPTIONS', None)}
+env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
+
+# We need this in order to run under ASAN, in case only LLDB is 
ASANified.
+asan_options = os.getenv('ASAN_OPTIONS', None)
+if (asan_options is not None):
+env['ASAN_OPTIONS'] = asan_options
 
 self.driver_exe = self.getBuildArtifact("multi-process-driver")
 self.buildDriver('multi-process-driver.cpp', self.driver_exe)



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


[Lldb-commits] [PATCH] D143690: [lldb] Add the ability to provide a message to a progress event update

2023-02-10 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added a comment.

details is good, thanks


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

https://reviews.llvm.org/D143690

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


[Lldb-commits] [PATCH] D143698: Support Debugging TLS variable with lldb

2023-02-10 Thread Kamlesh Kumar via Phabricator via lldb-commits
kkcode0 updated this revision to Diff 496654.
kkcode0 added a comment.

added comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143698

Files:
  lldb/include/lldb/Target/RegisterContext.h


Index: lldb/include/lldb/Target/RegisterContext.h
===
--- lldb/include/lldb/Target/RegisterContext.h
+++ lldb/include/lldb/Target/RegisterContext.h
@@ -37,6 +37,13 @@
 
   virtual lldb::ByteOrder GetByteOrder();
 
+  /// Retrieves the per-thread data area.
+  /// Most OSs maintain a per-thread pointer (e.g. the FS register on
+  /// x64), which we return the value of here.
+  ///
+  /// \return
+  /// LLDB_INVALID_ADDRESS if not supported, otherwise the thread
+  /// pointer value.
   virtual uint64_t GetThreadPointer();
 
   virtual bool ReadRegister(const RegisterInfo *reg_info,


Index: lldb/include/lldb/Target/RegisterContext.h
===
--- lldb/include/lldb/Target/RegisterContext.h
+++ lldb/include/lldb/Target/RegisterContext.h
@@ -37,6 +37,13 @@
 
   virtual lldb::ByteOrder GetByteOrder();
 
+  /// Retrieves the per-thread data area.
+  /// Most OSs maintain a per-thread pointer (e.g. the FS register on
+  /// x64), which we return the value of here.
+  ///
+  /// \return
+  /// LLDB_INVALID_ADDRESS if not supported, otherwise the thread
+  /// pointer value.
   virtual uint64_t GetThreadPointer();
 
   virtual bool ReadRegister(const RegisterInfo *reg_info,
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D143698: Support Debugging TLS variable with lldb

2023-02-10 Thread Kamlesh Kumar via Phabricator via lldb-commits
kkcode0 updated this revision to Diff 496655.
kkcode0 added a comment.

added comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143698

Files:
  lldb/include/lldb/Host/common/NativeRegisterContext.h
  lldb/include/lldb/Target/RegisterContext.h
  lldb/include/lldb/Utility/StringExtractorGDBRemote.h
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Host/common/NativeRegisterContext.cpp
  lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
  lldb/source/Target/RegisterContext.cpp
  lldb/source/Target/Thread.cpp
  lldb/source/Utility/StringExtractorGDBRemote.cpp
  lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py

Index: lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py
===
--- lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py
+++ lldb/test/API/lang/c/tls_globals/TestTlsGlobals.py
@@ -35,11 +35,7 @@
 
 # TLS works differently on Windows, this would need to be implemented
 # separately.
-@skipIfWindows
-@expectedFailureAll(
-bugnumber="llvm.org/pr28392",
-oslist=no_match(
-lldbplatformutil.getDarwinOSTriples()))
+@skipIf(archs=no_match(['x86_64']), oslist=no_match(['linux']))
 def test(self):
 """Test thread-local storage."""
 self.build()
Index: lldb/source/Utility/StringExtractorGDBRemote.cpp
===
--- lldb/source/Utility/StringExtractorGDBRemote.cpp
+++ lldb/source/Utility/StringExtractorGDBRemote.cpp
@@ -210,6 +210,8 @@
 return eServerPacketType_qGetProfileData;
   if (PACKET_MATCHES("qGDBServerVersion"))
 return eServerPacketType_qGDBServerVersion;
+  if (PACKET_STARTS_WITH("qGetTLSAddr"))
+	  return eServerPacketType_qGetTLSAddr;
   break;
 
 case 'H':
Index: lldb/source/Target/Thread.cpp
===
--- lldb/source/Target/Thread.cpp
+++ lldb/source/Target/Thread.cpp
@@ -1647,7 +1647,11 @@
 
 void Thread::SettingsTerminate() {}
 
-lldb::addr_t Thread::GetThreadPointer() { return LLDB_INVALID_ADDRESS; }
+lldb::addr_t Thread::GetThreadPointer() {
+  RegisterContext *reg_ctx = this->GetRegisterContext().get();
+  auto tp = reg_ctx->GetThreadPointer();
+  return tp;
+}
 
 addr_t Thread::GetThreadLocalData(const ModuleSP module,
   lldb::addr_t tls_file_addr) {
Index: lldb/source/Target/RegisterContext.cpp
===
--- lldb/source/Target/RegisterContext.cpp
+++ lldb/source/Target/RegisterContext.cpp
@@ -29,6 +29,10 @@
 
 RegisterContext::~RegisterContext() = default;
 
+uint64_t RegisterContext::GetThreadPointer() {
+  return UINT64_MAX;
+}
+
 void RegisterContext::InvalidateIfNeeded(bool force) {
   ProcessSP process_sp(m_thread.GetProcess());
   bool invalidate = force;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h
@@ -55,6 +55,8 @@
 
   const RegisterInfo *GetRegisterInfoAtIndex(size_t reg) override;
 
+  uint64_t GetThreadPointer() override;
+
   size_t GetRegisterSetCount() override;
 
   const RegisterSet *GetRegisterSet(size_t reg_set) override;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -80,6 +80,19 @@
   return m_reg_info_sp->GetRegisterSet(reg_set);
 }
 
+uint64_t GDBRemoteRegisterContext::GetThreadPointer() {
+  ExecutionContext exe_ctx(CalculateThread());
+  Process *process = exe_ctx.GetProcessPtr();
+  Thread *thread = exe_ctx.GetThreadPtr();
+  if (process == nullptr || thread == nullptr)
+return LLDB_INVALID_ADDRESS;
+  GDBRemoteCommunicationClient &gdb_comm(
+  ((ProcessGDBRemote *)process)->GetGDBRemote());
+  uint64_