[Lldb-commits] [lldb] 4c8ea90 - [LLDB] Fix LLDB buildbots break due to --image-base

2021-10-26 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2021-10-26T12:07:16+05:00
New Revision: 4c8ea90b252eeead9a6943f67444a229147949fb

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

LOG: [LLDB] Fix LLDB buildbots break due to --image-base

LLDB build were failing due to following two test failures:
lldb-shell :: ObjectFile/ELF/basic-info.yaml
lldb-shell :: SymbolFile/DWARF/x86/debug-types-address-ranges.s

There were caused by commit 6506907a0a1a8a789ad7036ef911f7e31213c9a5

Added: 


Modified: 
lldb/test/Shell/ObjectFile/ELF/basic-info.yaml
lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-address-ranges.s

Removed: 




diff  --git a/lldb/test/Shell/ObjectFile/ELF/basic-info.yaml 
b/lldb/test/Shell/ObjectFile/ELF/basic-info.yaml
index f9b9e10b07407..13d81bb921f28 100644
--- a/lldb/test/Shell/ObjectFile/ELF/basic-info.yaml
+++ b/lldb/test/Shell/ObjectFile/ELF/basic-info.yaml
@@ -1,7 +1,7 @@
 # REQUIRES: lld
 
 # RUN: yaml2obj %s -o %t.o
-# RUN: ld.lld %t.o -o %t -image-base 0x47000
+# RUN: ld.lld %t.o -o %t --image-base 0x47000
 # RUN: lldb-test object-file %t | FileCheck %s
 
 # CHECK: Plugin name: elf

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-address-ranges.s 
b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-address-ranges.s
index 2d5a9ae515d05..8b3b0e9d56956 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-address-ranges.s
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-address-ranges.s
@@ -7,7 +7,7 @@
 # REQUIRES: lld
 
 # RUN: llvm-mc -dwarf-version=5 -triple x86_64-pc-linux %s -filetype=obj >%t.o
-# RUN: ld.lld %t.o -o %t -image-base=0x47000 -z separate-code
+# RUN: ld.lld %t.o -o %t --image-base=0x47000 -z separate-code
 # RUN: %lldb %t -o "image lookup -a 0x48000 -v" -o exit | FileCheck %s
 
 # CHECK:   CompileUnit: id = {0x0001}, file = "/tmp/a.cc", language = "c++"



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


[Lldb-commits] [PATCH] D112169: [lldb] [Communication] Add a WriteAll() method that resumes writing

2021-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Maybe a quick unit test which send like 1MB of data in a single call or 
something similar?




Comment at: lldb/include/lldb/Core/Communication.h:195
   /// The actual write function that attempts to write to the communications
   /// protocol.
   ///

It might be worthwhile to emphasize that this will happily return after a 
partial write and point the reader to WriteAll if he wants to write everything.



Comment at: lldb/source/Core/Communication.cpp:29
 #include 
+#include 
 

delete



Comment at: lldb/source/Core/Communication.cpp:200
+total_written += written;
+if (status != eConnectionStatusSuccess || total_written >= src_len)
+  break;

It looks like this could be a do-while loop.


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

https://reviews.llvm.org/D112169

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


[Lldb-commits] [PATCH] D112310: [lldb/DWARF] Don't create lldb_private::Functions for gc'ed DW_TAG_subprograms

2021-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:866
+  // discontiguous)
+  AddressRange func_range;
+  lldb::addr_t lowest_func_addr = ranges.GetMinRangeBase(0);

shafik wrote:
> You declare `func_range` here but don't use it till the next block, did you 
> mean to use it in this block?
This probably started out as a single block, but I later split it in two when 
it got more complex. I'll move the declaration further down.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112310

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


[Lldb-commits] [lldb] b69564d - [lldb/DWARF] Move a declaration closer to its use

2021-10-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-26T09:58:10+02:00
New Revision: b69564d94d90b83ccdcc501f811959c23aeec52a

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

LOG: [lldb/DWARF] Move a declaration closer to its use

Adresses post-commit feedback on D112310.

Added: 


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

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index ad5b44365054a..f8715398a052e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -863,7 +863,6 @@ Function *SymbolFileDWARF::ParseFunction(CompileUnit 
&comp_unit,
 
   // Union of all ranges in the function DIE (if the function is
   // discontiguous)
-  AddressRange func_range;
   lldb::addr_t lowest_func_addr = ranges.GetMinRangeBase(0);
   lldb::addr_t highest_func_addr = ranges.GetMaxRangeEnd(0);
   if (lowest_func_addr == LLDB_INVALID_ADDRESS ||
@@ -872,6 +871,7 @@ Function *SymbolFileDWARF::ParseFunction(CompileUnit 
&comp_unit,
 return nullptr;
 
   ModuleSP module_sp(die.GetModule());
+  AddressRange func_range;
   func_range.GetBaseAddress().ResolveAddressUsingFileSections(
   lowest_func_addr, module_sp->GetSectionList());
   if (!func_range.GetBaseAddress().IsValid())



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


[Lldb-commits] [lldb] a458ef4 - [lldb] Remove ConstString from Platform plugin names

2021-10-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-26T10:04:35+02:00
New Revision: a458ef4f732b27312d8a5d20d2843d8bff35daeb

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

LOG: [lldb] Remove ConstString from Platform plugin names

Added: 


Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/include/lldb/Target/Platform.h
lldb/source/API/SBDebugger.cpp
lldb/source/Commands/CommandObjectPlatform.cpp
lldb/source/Core/IOHandlerCursesGUI.cpp
lldb/source/Core/PluginManager.cpp

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
lldb/source/Plugins/Platform/Android/PlatformAndroid.h
lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
lldb/source/Plugins/Platform/Linux/PlatformLinux.h
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
lldb/source/Plugins/Platform/Windows/PlatformWindows.h
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Target/Platform.cpp
lldb/unittests/Target/RemoteAwarePlatformTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index 97f8dae1bcfd2..aa51069cf4539 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -211,7 +211,7 @@ class PluginManager {
 
   // Platform
   static bool
-  RegisterPlugin(ConstString name, const char *description,
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  PlatformCreateInstance create_callback,
  DebuggerInitializeCallback debugger_init_callback = nullptr);
 
@@ -220,11 +220,11 @@ class PluginManager {
   static PlatformCreateInstance GetPlatformCreateCallbackAtIndex(uint32_t idx);
 
   static PlatformCreateInstance
-  GetPlatformCreateCallbackForPluginName(ConstString name);
+  GetPlatformCreateCallbackForPluginName(llvm::StringRef name);
 
-  static const char *GetPlatformPluginNameAtIndex(uint32_t idx);
+  static llvm::StringRef GetPlatformPluginNameAtIndex(uint32_t idx);
 
-  static const char *GetPlatformPluginDescriptionAtIndex(uint32_t idx);
+  static llvm::StringRef GetPlatformPluginDescriptionAtIndex(uint32_t idx);
 
   static void AutoCompletePlatformName(llvm::StringRef partial_name,
CompletionRequest &request);

diff  --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index d1351d5c729b4..adf6d865ab184 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -223,7 +223,7 @@ class Platform : public PluginInterface {
 
   virtual ConstString GetFullNameForDylib(ConstString basename);
 
-  virtual const char *GetDescription() = 0;
+  virtual llvm::StringRef GetDescription() = 0;
 
   /// Report the current status for this platform.
   ///

diff  --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index d044061fb0e40..c22662d764a7f 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1114,7 +1114,7 @@ uint32_t SBDebugger::GetNumAvailablePlatforms() {
 
   uint32_t idx = 0;
   while (true) {
-if (!PluginManager::GetPlatformPluginNameAtIndex(idx)) {
+if (PluginManager::GetPlatformPluginNameAtIndex(i

[Lldb-commits] [PATCH] D112457: Modernize and simplify HostInfo::GetOSKernelDescription

2021-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath updated this revision to Diff 382223.
labath marked 2 inline comments as done.
labath added a comment.

Remove memset


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112457

Files:
  lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
  lldb/include/lldb/Host/linux/HostInfoLinux.h
  lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
  lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
  lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
  lldb/include/lldb/Host/posix/HostInfoPosix.h
  lldb/include/lldb/Host/windows/HostInfoWindows.h
  lldb/source/Host/freebsd/HostInfoFreeBSD.cpp
  lldb/source/Host/linux/HostInfoLinux.cpp
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
  lldb/source/Host/netbsd/HostInfoNetBSD.cpp
  lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
  lldb/source/Host/posix/HostInfoPosix.cpp
  lldb/source/Host/windows/HostInfoWindows.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Target/Platform.cpp

Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -493,8 +493,11 @@
 }
 
 bool Platform::GetOSKernelDescription(std::string &s) {
-  if (IsHost())
-return HostInfo::GetOSKernelDescription(s);
+  if (IsHost()) {
+llvm::Optional desc = HostInfo::GetOSKernelDescription();
+s = desc.getValueOr("");
+return desc.hasValue();
+  }
   return GetRemoteOSKernelDescription(s);
 }
 
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -272,13 +272,13 @@
 response.PutStringAsRawHex8(*s);
 response.PutChar(';');
   }
-  std::string s;
-  if (HostInfo::GetOSKernelDescription(s)) {
+  if (llvm::Optional s = HostInfo::GetOSKernelDescription()) {
 response.PutCString("os_kernel:");
-response.PutStringAsRawHex8(s);
+response.PutStringAsRawHex8(*s);
 response.PutChar(';');
   }
 
+  std::string s;
 #if defined(__APPLE__)
 
 #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
Index: lldb/source/Host/windows/HostInfoWindows.cpp
===
--- lldb/source/Host/windows/HostInfoWindows.cpp
+++ lldb/source/Host/windows/HostInfoWindows.cpp
@@ -82,10 +82,8 @@
   return "Windows NT " + version.getAsString();
 }
 
-bool HostInfoWindows::GetOSKernelDescription(std::string &s) {
-  llvm::Optional build = GetOSBuildString();
-  s = build.getValueOr("");
-  return build.hasValue();
+llvm::Optional HostInfoWindows::GetOSKernelDescription() {
+  return GetOSBuildString();
 }
 
 bool HostInfoWindows::GetHostname(std::string &s) {
Index: lldb/source/Host/posix/HostInfoPosix.cpp
===
--- lldb/source/Host/posix/HostInfoPosix.cpp
+++ lldb/source/Host/posix/HostInfoPosix.cpp
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 using namespace lldb_private;
@@ -37,6 +38,14 @@
   return false;
 }
 
+llvm::Optional HostInfoPosix::GetOSKernelDescription() {
+  struct utsname un;
+  if (uname(&un) < 0)
+return llvm::None;
+
+  return std::string(un.version);
+}
+
 #ifdef __ANDROID__
 #include 
 #endif
Index: lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
===
--- lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
+++ lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
@@ -41,20 +41,6 @@
   return llvm::None;
 }
 
-bool HostInfoOpenBSD::GetOSKernelDescription(std::string &s) {
-  struct utsname un;
-
-  ::memset(&un, 0, sizeof(utsname));
-  s.clear();
-
-  if (uname(&un) < 0)
-return false;
-
-  s.assign(un.version);
-
-  return true;
-}
-
 FileSpec HostInfoOpenBSD::GetProgramFileSpec() {
   static FileSpec g_program_filespec;
   return g_program_filespec;
Index: lldb/source/Host/netbsd/HostInfoNetBSD.cpp
===
--- lldb/source/Host/netbsd/HostInfoNetBSD.cpp
+++ lldb/source/Host/netbsd/HostInfoNetBSD.cpp
@@ -54,20 +54,6 @@
   return llvm::None;
 }
 
-bool HostInfoNetBSD::GetOSKernelDescription(std::string &s) {
-  struct utsname un;
-
-  ::memset(&un, 0, sizeof(un));
-  s.clear();
-
-  if (::uname(&un) < 0)
-return false;
-
-  s.assign(un.version);
-
-  return true;
-}
-
 FileSpec HostInfoNetBSD::GetProgramFileSpec() {
   static FileSpec g_program_filespec;
 
Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -65,18 +65,6 @@
   return

[Lldb-commits] [PATCH] D112457: Modernize and simplify HostInfo::GetOSKernelDescription

2021-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/source/Host/posix/HostInfoPosix.cpp:44
+
+  ::memset(&un, 0, sizeof(utsname));
+

mgorny wrote:
> I'm somewhat surprised that you need to do that. I wonder if there was a real 
> reason why it's done or just someone being overly careful.
I'm pretty sure it isn't necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112457

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


[Lldb-commits] [PATCH] D112169: [lldb] [Communication] Add a WriteAll() method that resumes writing

2021-10-26 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 382227.
mgorny marked 2 inline comments as done.
mgorny added a comment.

Implemented requested changes. Added a minimal-ish unittest.


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

https://reviews.llvm.org/D112169

Files:
  lldb/include/lldb/Core/Communication.h
  lldb/source/Core/Communication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/unittests/Core/CommunicationTest.cpp

Index: lldb/unittests/Core/CommunicationTest.cpp
===
--- lldb/unittests/Core/CommunicationTest.cpp
+++ lldb/unittests/Core/CommunicationTest.cpp
@@ -7,11 +7,18 @@
 //===--===//
 
 #include "lldb/Core/Communication.h"
+#include "lldb/Host/Config.h"
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/Pipe.h"
 #include "llvm/Testing/Support/Error.h"
 #include "gtest/gtest.h"
 
+#include 
+
+#if LLDB_ENABLE_POSIX
+#include 
+#endif
+
 using namespace lldb_private;
 
 #ifndef _WIN32
@@ -35,3 +42,48 @@
   ASSERT_TRUE(comm.StopReadThread());
 }
 #endif
+
+#if LLDB_ENABLE_POSIX
+TEST(CommunicationTest, WriteAll) {
+  Pipe pipe;
+  ASSERT_THAT_ERROR(pipe.CreateNew(/*child_process_inherit=*/false).ToError(),
+llvm::Succeeded());
+
+  // Make the write end non-blocking in order to easily reproduce a partial
+  // write.
+  int write_fd = pipe.ReleaseWriteFileDescriptor();
+  int flags = fcntl(write_fd, F_GETFL);
+  ASSERT_NE(flags, -1);
+  ASSERT_NE(fcntl(write_fd, F_SETFL, flags | O_NONBLOCK), -1);
+
+  ConnectionFileDescriptor read_conn{pipe.ReleaseReadFileDescriptor(),
+ /*owns_fd=*/true};
+  Communication write_comm("test");
+  write_comm.SetConnection(
+  std::make_unique(write_fd, /*owns_fd=*/true));
+
+  std::thread read_thread{[&read_conn]() {
+// Read using a smaller buffer to increase chances of partial write.
+char buf[128 * 1024];
+lldb::ConnectionStatus conn_status;
+
+do {
+  read_conn.Read(buf, sizeof(buf), std::chrono::seconds(1), conn_status,
+ nullptr);
+} while (conn_status != lldb::eConnectionStatusEndOfFile);
+  }};
+
+  // Write 1 MiB of data into the pipe.
+  lldb::ConnectionStatus conn_status;
+  Status error;
+  std::vector data(1024 * 1024, 0x80);
+  EXPECT_EQ(write_comm.WriteAll(data.data(), data.size(), conn_status, &error),
+data.size());
+  EXPECT_EQ(conn_status, lldb::eConnectionStatusSuccess);
+  EXPECT_FALSE(error.Fail());
+
+  // Close the write end in order to trigger EOF.
+  write_comm.Disconnect();
+  read_thread.join();
+}
+#endif
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -101,7 +101,7 @@
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
   ConnectionStatus status = eConnectionStatusSuccess;
   char ch = '+';
-  const size_t bytes_written = Write(&ch, 1, status, nullptr);
+  const size_t bytes_written = WriteAll(&ch, 1, status, nullptr);
   LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
   m_history.AddPacket(ch, GDBRemotePacket::ePacketTypeSend, bytes_written);
   return bytes_written;
@@ -111,7 +111,7 @@
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
   ConnectionStatus status = eConnectionStatusSuccess;
   char ch = '-';
-  const size_t bytes_written = Write(&ch, 1, status, nullptr);
+  const size_t bytes_written = WriteAll(&ch, 1, status, nullptr);
   LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
   m_history.AddPacket(ch, GDBRemotePacket::ePacketTypeSend, bytes_written);
   return bytes_written;
@@ -137,7 +137,7 @@
 ConnectionStatus status = eConnectionStatusSuccess;
 const char *packet_data = packet.data();
 const size_t packet_length = packet.size();
-size_t bytes_written = Write(packet_data, packet_length, status, nullptr);
+size_t bytes_written = WriteAll(packet_data, packet_length, status, nullptr);
 if (log) {
   size_t binary_start_offset = 0;
   if (strncmp(packet_data, "$vFile:pwrite:", strlen("$vFile:pwrite:")) ==
Index: lldb/source/Core/Communication.cpp
===
--- lldb/source/Core/Communication.cpp
+++ lldb/source/Core/Communication.cpp
@@ -189,6 +189,16 @@
   return 0;
 }
 
+size_t Communication::WriteAll(const void *src, size_t src_len,
+   ConnectionStatus &status, Status *error_ptr) {
+  size_t total_written = 0;
+  do
+total_written += Write(static_cast(src) + total_written,
+   src_len - total_written, status, error_ptr);
+  wh

[Lldb-commits] [PATCH] D112169: [lldb] [Communication] Add a WriteAll() method that resumes writing

2021-10-26 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: lldb/source/Core/Communication.cpp:200
+total_written += written;
+if (status != eConnectionStatusSuccess || total_written >= src_len)
+  break;

labath wrote:
> It looks like this could be a do-while loop.
Ah, yes, without the sleep it makes sense.


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

https://reviews.llvm.org/D112169

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


[Lldb-commits] [PATCH] D112457: Modernize and simplify HostInfo::GetOSKernelDescription

2021-10-26 Thread Michał Górny via Phabricator via lldb-commits
mgorny accepted this revision.
mgorny added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112457

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


[Lldb-commits] [PATCH] D112169: [lldb] [Communication] Add a WriteAll() method that resumes writing

2021-10-26 Thread Michał Górny via Phabricator via lldb-commits
mgorny added inline comments.



Comment at: lldb/unittests/Core/CommunicationTest.cpp:80
+  std::vector data(1024 * 1024, 0x80);
+  EXPECT_EQ(write_comm.WriteAll(data.data(), data.size(), conn_status, &error),
+data.size());

If we want to be super-strict, I can add an another `Write()` call above to 
verify that a partial write happens — but I'm not sure if we should fail on 
that.


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

https://reviews.llvm.org/D112169

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


[Lldb-commits] [lldb] 0a39a9c - Modernize and simplify HostInfo::GetOSKernelDescription

2021-10-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-26T11:17:02+02:00
New Revision: 0a39a9c2cb43f93c82908cabdf73fdd4918a26e5

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

LOG: Modernize and simplify HostInfo::GetOSKernelDescription

Replace bool+by-ref argument with llvm::Optional, and move the common
implementation into HostInfoPOSIX. Based on my (simple) experiment,
the uname and the sysctl approach return the same value on MacOS, so
there's no need for a mac-specific implementation of this functionality.

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

Added: 


Modified: 
lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
lldb/include/lldb/Host/linux/HostInfoLinux.h
lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
lldb/include/lldb/Host/posix/HostInfoPosix.h
lldb/include/lldb/Host/windows/HostInfoWindows.h
lldb/source/Host/freebsd/HostInfoFreeBSD.cpp
lldb/source/Host/linux/HostInfoLinux.cpp
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
lldb/source/Host/netbsd/HostInfoNetBSD.cpp
lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
lldb/source/Host/posix/HostInfoPosix.cpp
lldb/source/Host/windows/HostInfoWindows.cpp

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
lldb/source/Target/Platform.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h 
b/lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
index 8207e9093f71..b2f3f08cd145 100644
--- a/lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
+++ b/lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
@@ -19,7 +19,6 @@ class HostInfoFreeBSD : public HostInfoPosix {
 public:
   static llvm::VersionTuple GetOSVersion();
   static llvm::Optional GetOSBuildString();
-  static bool GetOSKernelDescription(std::string &s);
   static FileSpec GetProgramFileSpec();
 };
 }

diff  --git a/lldb/include/lldb/Host/linux/HostInfoLinux.h 
b/lldb/include/lldb/Host/linux/HostInfoLinux.h
index 628767060664..e2167b8a883d 100644
--- a/lldb/include/lldb/Host/linux/HostInfoLinux.h
+++ b/lldb/include/lldb/Host/linux/HostInfoLinux.h
@@ -27,7 +27,6 @@ class HostInfoLinux : public HostInfoPosix {
 
   static llvm::VersionTuple GetOSVersion();
   static llvm::Optional GetOSBuildString();
-  static bool GetOSKernelDescription(std::string &s);
   static llvm::StringRef GetDistributionId();
   static FileSpec GetProgramFileSpec();
 

diff  --git a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h 
b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
index 42c2872af218..de7ecc1e6d80 100644
--- a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
+++ b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
@@ -25,7 +25,6 @@ class HostInfoMacOSX : public HostInfoPosix {
   static llvm::VersionTuple GetOSVersion();
   static llvm::VersionTuple GetMacCatalystVersion();
   static llvm::Optional GetOSBuildString();
-  static bool GetOSKernelDescription(std::string &s);
   static FileSpec GetProgramFileSpec();
   static FileSpec GetXcodeContentsDirectory();
   static FileSpec GetXcodeDeveloperDirectory();

diff  --git a/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h 
b/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
index 021f8626733b..32644ce79a69 100644
--- a/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
+++ b/lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
@@ -19,7 +19,6 @@ class HostInfoNetBSD : public HostInfoPosix {
 public:
   static llvm::VersionTuple GetOSVersion();
   static llvm::Optional GetOSBuildString();
-  static bool GetOSKernelDescription(std::string &s);
   static FileSpec GetProgramFileSpec();
 };
 }

diff  --git a/lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h 
b/lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
index ba5ac8cbb169..01879ad5c0e4 100644
--- a/lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
+++ b/lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
@@ -19,7 +19,6 @@ class HostInfoOpenBSD : public HostInfoPosix {
 public:
   static llvm::VersionTuple GetOSVersion();
   static llvm::Optional GetOSBuildString();
-  static bool GetOSKernelDescription(std::string &s);
   static FileSpec GetProgramFileSpec();
 };
 }

diff  --git a/lldb/include/lldb/Host/posix/HostInfoPosix.h 
b/lldb/include/lldb/Host/posix/HostInfoPosix.h
index 825c79f53ecb..f1ff6b860864 100644
--- a/lldb/include/lldb/Host/posix/HostInfoPosix.h
+++ b/lldb/include/lldb/Host/posix/HostInfoPosix.h
@@ -22,6 +22,7 @@ class HostInfoPosix : public HostInfoBase {
 public:
   static size_t GetPageSize();
   static bool GetHostname(std::string &s);
+  static llvm::Optional GetOSKernelDescription();
 
   static uint32_t GetUserID();
   static uint32_t GetGroupID();

diff  --git a/lldb/include/lldb/Host/windows/Ho

[Lldb-commits] [PATCH] D112457: Modernize and simplify HostInfo::GetOSKernelDescription

2021-10-26 Thread Pavel Labath via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0a39a9c2cb43: Modernize and simplify 
HostInfo::GetOSKernelDescription (authored by labath).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112457

Files:
  lldb/include/lldb/Host/freebsd/HostInfoFreeBSD.h
  lldb/include/lldb/Host/linux/HostInfoLinux.h
  lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
  lldb/include/lldb/Host/netbsd/HostInfoNetBSD.h
  lldb/include/lldb/Host/openbsd/HostInfoOpenBSD.h
  lldb/include/lldb/Host/posix/HostInfoPosix.h
  lldb/include/lldb/Host/windows/HostInfoWindows.h
  lldb/source/Host/freebsd/HostInfoFreeBSD.cpp
  lldb/source/Host/linux/HostInfoLinux.cpp
  lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
  lldb/source/Host/netbsd/HostInfoNetBSD.cpp
  lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
  lldb/source/Host/posix/HostInfoPosix.cpp
  lldb/source/Host/windows/HostInfoWindows.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Target/Platform.cpp

Index: lldb/source/Target/Platform.cpp
===
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -493,8 +493,11 @@
 }
 
 bool Platform::GetOSKernelDescription(std::string &s) {
-  if (IsHost())
-return HostInfo::GetOSKernelDescription(s);
+  if (IsHost()) {
+llvm::Optional desc = HostInfo::GetOSKernelDescription();
+s = desc.getValueOr("");
+return desc.hasValue();
+  }
   return GetRemoteOSKernelDescription(s);
 }
 
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
@@ -272,13 +272,13 @@
 response.PutStringAsRawHex8(*s);
 response.PutChar(';');
   }
-  std::string s;
-  if (HostInfo::GetOSKernelDescription(s)) {
+  if (llvm::Optional s = HostInfo::GetOSKernelDescription()) {
 response.PutCString("os_kernel:");
-response.PutStringAsRawHex8(s);
+response.PutStringAsRawHex8(*s);
 response.PutChar(';');
   }
 
+  std::string s;
 #if defined(__APPLE__)
 
 #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
Index: lldb/source/Host/windows/HostInfoWindows.cpp
===
--- lldb/source/Host/windows/HostInfoWindows.cpp
+++ lldb/source/Host/windows/HostInfoWindows.cpp
@@ -82,10 +82,8 @@
   return "Windows NT " + version.getAsString();
 }
 
-bool HostInfoWindows::GetOSKernelDescription(std::string &s) {
-  llvm::Optional build = GetOSBuildString();
-  s = build.getValueOr("");
-  return build.hasValue();
+llvm::Optional HostInfoWindows::GetOSKernelDescription() {
+  return GetOSBuildString();
 }
 
 bool HostInfoWindows::GetHostname(std::string &s) {
Index: lldb/source/Host/posix/HostInfoPosix.cpp
===
--- lldb/source/Host/posix/HostInfoPosix.cpp
+++ lldb/source/Host/posix/HostInfoPosix.cpp
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 using namespace lldb_private;
@@ -37,6 +38,14 @@
   return false;
 }
 
+llvm::Optional HostInfoPosix::GetOSKernelDescription() {
+  struct utsname un;
+  if (uname(&un) < 0)
+return llvm::None;
+
+  return std::string(un.version);
+}
+
 #ifdef __ANDROID__
 #include 
 #endif
Index: lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
===
--- lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
+++ lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
@@ -41,20 +41,6 @@
   return llvm::None;
 }
 
-bool HostInfoOpenBSD::GetOSKernelDescription(std::string &s) {
-  struct utsname un;
-
-  ::memset(&un, 0, sizeof(utsname));
-  s.clear();
-
-  if (uname(&un) < 0)
-return false;
-
-  s.assign(un.version);
-
-  return true;
-}
-
 FileSpec HostInfoOpenBSD::GetProgramFileSpec() {
   static FileSpec g_program_filespec;
   return g_program_filespec;
Index: lldb/source/Host/netbsd/HostInfoNetBSD.cpp
===
--- lldb/source/Host/netbsd/HostInfoNetBSD.cpp
+++ lldb/source/Host/netbsd/HostInfoNetBSD.cpp
@@ -54,20 +54,6 @@
   return llvm::None;
 }
 
-bool HostInfoNetBSD::GetOSKernelDescription(std::string &s) {
-  struct utsname un;
-
-  ::memset(&un, 0, sizeof(un));
-  s.clear();
-
-  if (::uname(&un) < 0)
-return false;
-
-  s.assign(un.version);
-
-  return true;
-}
-
 FileSpec HostInfoNetBSD::GetProgramFileSpec() {
   static FileSpec g_program_filespec;
 
Index: lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
===
--- lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ lldb/source/Host/

[Lldb-commits] [PATCH] D112439: normalize file path when searching the source map

2021-10-26 Thread Xu Jun via Phabricator via lldb-commits
xujuntwt95329 updated this revision to Diff 382235.
xujuntwt95329 added a comment.
Herald added a subscriber: mgorny.

add unittest


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112439

Files:
  lldb/source/Target/PathMappingList.cpp
  lldb/unittests/Target/CMakeLists.txt
  lldb/unittests/Target/FindFileTest.cpp

Index: lldb/unittests/Target/FindFileTest.cpp
===
--- /dev/null
+++ lldb/unittests/Target/FindFileTest.cpp
@@ -0,0 +1,97 @@
+//===-- FindFileTest.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestingSupport/TestUtilities.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/PathMappingList.h"
+#include "lldb/Utility/FileSpec.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::sys::fs;
+using namespace lldb_private;
+
+namespace {
+struct Matches {
+  FileSpec original;
+  llvm::StringRef remapped;
+  Matches(const char *o, const char *r) : original(o), remapped(r) {}
+  Matches(const char *o, llvm::sys::path::Style style, const char *r)
+  : original(o, style), remapped(r) {}
+};
+
+class FindFileTest : public testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+  }
+  void TearDown() override {
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+} // namespace
+
+static void TestFileFindings(const PathMappingList &map,
+ llvm::ArrayRef matches,
+ llvm::ArrayRef fails) {
+  for (const auto &fail : fails) {
+SCOPED_TRACE(fail.GetCString());
+EXPECT_FALSE(map.FindFile(fail));
+  }
+
+  for (const auto &match : matches) {
+SCOPED_TRACE(match.original.GetPath() + " -> " + match.remapped);
+llvm::Optional remapped;
+
+EXPECT_TRUE(bool(remapped = map.FindFile(match.original)));
+EXPECT_TRUE(FileSpec(remapped.getValue()).GetPath() ==
+ConstString(match.remapped).GetStringRef());
+  }
+}
+
+TEST_F(FindFileTest, FindFileTests) {
+  const auto *Info = testing::UnitTest::GetInstance()->current_test_info();
+  llvm::SmallString<128> DirName, FileName;
+  int fd;
+
+  ASSERT_NO_ERROR(createUniqueDirectory(Info->name(), DirName));
+
+  sys::path::append(FileName, Twine(DirName), Twine("test"));
+  ASSERT_NO_ERROR(openFile(FileName, fd, CD_CreateAlways, FA_Read, OF_None));
+
+  llvm::FileRemover dir_remover(DirName);
+  llvm::FileRemover file_remover(FileName);
+  PathMappingList map;
+
+  map.Append(ConstString("/old"), ConstString(DirName.str()), false);
+  map.Append(ConstString(R"(C:\foo)"), ConstString(DirName.str()), false);
+
+  Matches matches[] = {
+  {"/old", llvm::sys::path::Style::posix, DirName.c_str()},
+  {"/old/test", llvm::sys::path::Style::posix, FileName.c_str()},
+  {R"(C:\foo)", llvm::sys::path::Style::windows, DirName.c_str()},
+  {R"(C:\foo\test)", llvm::sys::path::Style::windows, FileName.c_str()}};
+
+  ArrayRef fails{
+  // path not mapped
+  FileSpec("/foo", llvm::sys::path::Style::posix),
+  FileSpec("/new", llvm::sys::path::Style::posix),
+  FileSpec(R"(C:\new)", llvm::sys::path::Style::windows),
+  // path mapped, but file not exist
+  FileSpec("/test1", llvm::sys::path::Style::posix),
+  FileSpec(R"(C:\foo\test2)", llvm::sys::path::Style::windows)};
+
+  TestFileFindings(map, matches, fails);
+}
Index: lldb/unittests/Target/CMakeLists.txt
===
--- lldb/unittests/Target/CMakeLists.txt
+++ lldb/unittests/Target/CMakeLists.txt
@@ -7,6 +7,7 @@
   PathMappingListTest.cpp
   RemoteAwarePlatformTest.cpp
   StackFrameRecognizerTest.cpp
+  FindFileTest.cpp
 
   LINK_LIBS
   lldbCore
Index: lldb/source/Target/PathMappingList.cpp
===
--- lldb/source/Target/PathMappingList.cpp
+++ lldb/source/Target/PathMappingList.cpp
@@ -218,7 +218,12 @@
 }
 
 llvm::Optional PathMappingList::FindFile(const FileSpec &orig_spec) const {
-  if (auto remapped = RemapPath(orig_spec.GetPath(), /*only_if_exists=*/true))
+  // We must normalize the orig_spec again using the host's path style,
+  // otherwise there will be mismatch between the host and remote platform
+  // if they use different path styles.
+  if (auto remapped = RemapPath(
+  NormalizePath(ConstString(orig_spec.GetCString())).GetStringRef(),
+   

[Lldb-commits] [PATCH] D112439: normalize file path when searching the source map

2021-10-26 Thread Xu Jun via Phabricator via lldb-commits
xujuntwt95329 updated this revision to Diff 382237.
xujuntwt95329 added a comment.

minor fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112439

Files:
  lldb/source/Target/PathMappingList.cpp
  lldb/unittests/Target/CMakeLists.txt
  lldb/unittests/Target/FindFileTest.cpp

Index: lldb/unittests/Target/FindFileTest.cpp
===
--- /dev/null
+++ lldb/unittests/Target/FindFileTest.cpp
@@ -0,0 +1,97 @@
+//===-- FindFileTest.cpp -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TestingSupport/TestUtilities.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Host/HostInfo.h"
+#include "lldb/Target/PathMappingList.h"
+#include "lldb/Utility/FileSpec.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace llvm;
+using namespace llvm::sys::fs;
+using namespace lldb_private;
+
+namespace {
+struct Matches {
+  FileSpec original;
+  llvm::StringRef remapped;
+  Matches(const char *o, const char *r) : original(o), remapped(r) {}
+  Matches(const char *o, llvm::sys::path::Style style, const char *r)
+  : original(o, style), remapped(r) {}
+};
+
+class FindFileTest : public testing::Test {
+public:
+  void SetUp() override {
+FileSystem::Initialize();
+HostInfo::Initialize();
+  }
+  void TearDown() override {
+HostInfo::Terminate();
+FileSystem::Terminate();
+  }
+};
+} // namespace
+
+static void TestFileFindings(const PathMappingList &map,
+ llvm::ArrayRef matches,
+ llvm::ArrayRef fails) {
+  for (const auto &fail : fails) {
+SCOPED_TRACE(fail.GetCString());
+EXPECT_FALSE(map.FindFile(fail));
+  }
+
+  for (const auto &match : matches) {
+SCOPED_TRACE(match.original.GetPath() + " -> " + match.remapped);
+llvm::Optional remapped;
+
+EXPECT_TRUE(bool(remapped = map.FindFile(match.original)));
+EXPECT_TRUE(FileSpec(remapped.getValue()).GetPath() ==
+ConstString(match.remapped).GetStringRef());
+  }
+}
+
+TEST_F(FindFileTest, FindFileTests) {
+  const auto *Info = testing::UnitTest::GetInstance()->current_test_info();
+  llvm::SmallString<128> DirName, FileName;
+  int fd;
+
+  ASSERT_NO_ERROR(createUniqueDirectory(Info->name(), DirName));
+
+  sys::path::append(FileName, Twine(DirName), Twine("test"));
+  ASSERT_NO_ERROR(openFile(FileName, fd, CD_CreateAlways, FA_Read, OF_None));
+
+  llvm::FileRemover dir_remover(DirName);
+  llvm::FileRemover file_remover(FileName);
+  PathMappingList map;
+
+  map.Append(ConstString("/old"), ConstString(DirName.str()), false);
+  map.Append(ConstString(R"(C:\foo)"), ConstString(DirName.str()), false);
+
+  Matches matches[] = {
+  {"/old", llvm::sys::path::Style::posix, DirName.c_str()},
+  {"/old/test", llvm::sys::path::Style::posix, FileName.c_str()},
+  {R"(C:\foo)", llvm::sys::path::Style::windows, DirName.c_str()},
+  {R"(C:\foo\test)", llvm::sys::path::Style::windows, FileName.c_str()}};
+
+  ArrayRef fails{
+  // path not mapped
+  FileSpec("/foo", llvm::sys::path::Style::posix),
+  FileSpec("/new", llvm::sys::path::Style::posix),
+  FileSpec(R"(C:\new)", llvm::sys::path::Style::windows),
+  // path mapped, but file not exist
+  FileSpec("/old/test1", llvm::sys::path::Style::posix),
+  FileSpec(R"(C:\foo\test2)", llvm::sys::path::Style::windows)};
+
+  TestFileFindings(map, matches, fails);
+}
Index: lldb/unittests/Target/CMakeLists.txt
===
--- lldb/unittests/Target/CMakeLists.txt
+++ lldb/unittests/Target/CMakeLists.txt
@@ -7,6 +7,7 @@
   PathMappingListTest.cpp
   RemoteAwarePlatformTest.cpp
   StackFrameRecognizerTest.cpp
+  FindFileTest.cpp
 
   LINK_LIBS
   lldbCore
Index: lldb/source/Target/PathMappingList.cpp
===
--- lldb/source/Target/PathMappingList.cpp
+++ lldb/source/Target/PathMappingList.cpp
@@ -218,7 +218,12 @@
 }
 
 llvm::Optional PathMappingList::FindFile(const FileSpec &orig_spec) const {
-  if (auto remapped = RemapPath(orig_spec.GetPath(), /*only_if_exists=*/true))
+  // We must normalize the orig_spec again using the host's path style,
+  // otherwise there will be mismatch between the host and remote platform
+  // if they use different path styles.
+  if (auto remapped = RemapPath(
+  NormalizePath(ConstString(orig_spec.GetCString())).GetStringRef(),
+  /*only_if_exists=*/true))
 

[Lldb-commits] [PATCH] D112439: normalize file path when searching the source map

2021-10-26 Thread Xu Jun via Phabricator via lldb-commits
xujuntwt95329 added a comment.

I've added the unit test. 
The "FindFile" method requires the FileSystem, so I added a new file rather 
then put these code into exist PathMappingListTest.cpp

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112439

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


[Lldb-commits] [lldb] f279e50 - [lldb] [Communication] Add a WriteAll() method that resumes writing

2021-10-26 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-26T12:45:45+02:00
New Revision: f279e50fd0f0035e0205f4d36e7e5a8e0112fc24

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

LOG: [lldb] [Communication] Add a WriteAll() method that resumes writing

Add a Communication::WriteAll() that resumes Write() if the initial call
did not write all data.  Use it in GDBRemoteCommunication when sending
packets in order to fix handling partial writes (i.e. just resume/retry
them rather than erring out).  This fixes LLDB failures when writing
large packets to a pty.

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

Added: 


Modified: 
lldb/include/lldb/Core/Communication.h
lldb/source/Core/Communication.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/unittests/Core/CommunicationTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/Communication.h 
b/lldb/include/lldb/Core/Communication.h
index 930e927f6783..fdcb6c5fb982 100644
--- a/lldb/include/lldb/Core/Communication.h
+++ b/lldb/include/lldb/Core/Communication.h
@@ -209,6 +209,22 @@ class Communication : public Broadcaster {
   size_t Write(const void *src, size_t src_len, lldb::ConnectionStatus &status,
Status *error_ptr);
 
+  /// Repeatedly attempt writing until either \a src_len bytes are written
+  /// or a permanent failure occurs.
+  ///
+  /// \param[in] src
+  /// A source buffer that must be at least \a src_len bytes
+  /// long.
+  ///
+  /// \param[in] src_len
+  /// The number of bytes to attempt to write, and also the
+  /// number of bytes are currently available in \a src.
+  ///
+  /// \return
+  /// The number of bytes actually Written.
+  size_t WriteAll(const void *src, size_t src_len,
+  lldb::ConnectionStatus &status, Status *error_ptr);
+
   /// Sets the connection that it to be used by this class.
   ///
   /// By making a communication class that uses 
diff erent connections it

diff  --git a/lldb/source/Core/Communication.cpp 
b/lldb/source/Core/Communication.cpp
index fd20b58d18b4..0ad2751f24f0 100644
--- a/lldb/source/Core/Communication.cpp
+++ b/lldb/source/Core/Communication.cpp
@@ -189,6 +189,16 @@ size_t Communication::Write(const void *src, size_t 
src_len,
   return 0;
 }
 
+size_t Communication::WriteAll(const void *src, size_t src_len,
+   ConnectionStatus &status, Status *error_ptr) {
+  size_t total_written = 0;
+  do
+total_written += Write(static_cast(src) + total_written,
+   src_len - total_written, status, error_ptr);
+  while (status == eConnectionStatusSuccess && total_written < src_len);
+  return total_written;
+}
+
 bool Communication::StartReadThread(Status *error_ptr) {
   if (error_ptr)
 error_ptr->Clear();

diff  --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
index adc8d6f1e8d0..ae2141d30220 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -101,7 +101,7 @@ size_t GDBRemoteCommunication::SendAck() {
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
   ConnectionStatus status = eConnectionStatusSuccess;
   char ch = '+';
-  const size_t bytes_written = Write(&ch, 1, status, nullptr);
+  const size_t bytes_written = WriteAll(&ch, 1, status, nullptr);
   LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, 
ch);
   m_history.AddPacket(ch, GDBRemotePacket::ePacketTypeSend, bytes_written);
   return bytes_written;
@@ -111,7 +111,7 @@ size_t GDBRemoteCommunication::SendNack() {
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
   ConnectionStatus status = eConnectionStatusSuccess;
   char ch = '-';
-  const size_t bytes_written = Write(&ch, 1, status, nullptr);
+  const size_t bytes_written = WriteAll(&ch, 1, status, nullptr);
   LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, 
ch);
   m_history.AddPacket(ch, GDBRemotePacket::ePacketTypeSend, bytes_written);
   return bytes_written;
@@ -137,7 +137,7 @@ GDBRemoteCommunication::SendRawPacketNoLock(llvm::StringRef 
packet,
 ConnectionStatus status = eConnectionStatusSuccess;
 const char *packet_data = packet.data();
 const size_t packet_length = packet.size();
-size_t bytes_written = Write(packet_data, packet_length, status, nullptr);
+size_t bytes_written = WriteAll(packet_data, packet_length, status, 
nullptr);
 if (log) {
   size_t binary_start_offset = 0;
   if (strncmp(packet_data, "$vFile:pwrite:", strlen("$vFile:pwrite:")) ==

diff  --git a/lldb/unittests/Core/Comm

[Lldb-commits] [PATCH] D112169: [lldb] [Communication] Add a WriteAll() method that resumes writing

2021-10-26 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf279e50fd0f0: [lldb] [Communication] Add a WriteAll() method 
that resumes writing (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112169

Files:
  lldb/include/lldb/Core/Communication.h
  lldb/source/Core/Communication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/unittests/Core/CommunicationTest.cpp

Index: lldb/unittests/Core/CommunicationTest.cpp
===
--- lldb/unittests/Core/CommunicationTest.cpp
+++ lldb/unittests/Core/CommunicationTest.cpp
@@ -7,11 +7,18 @@
 //===--===//
 
 #include "lldb/Core/Communication.h"
+#include "lldb/Host/Config.h"
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/Pipe.h"
 #include "llvm/Testing/Support/Error.h"
 #include "gtest/gtest.h"
 
+#include 
+
+#if LLDB_ENABLE_POSIX
+#include 
+#endif
+
 using namespace lldb_private;
 
 #ifndef _WIN32
@@ -35,3 +42,48 @@
   ASSERT_TRUE(comm.StopReadThread());
 }
 #endif
+
+#if LLDB_ENABLE_POSIX
+TEST(CommunicationTest, WriteAll) {
+  Pipe pipe;
+  ASSERT_THAT_ERROR(pipe.CreateNew(/*child_process_inherit=*/false).ToError(),
+llvm::Succeeded());
+
+  // Make the write end non-blocking in order to easily reproduce a partial
+  // write.
+  int write_fd = pipe.ReleaseWriteFileDescriptor();
+  int flags = fcntl(write_fd, F_GETFL);
+  ASSERT_NE(flags, -1);
+  ASSERT_NE(fcntl(write_fd, F_SETFL, flags | O_NONBLOCK), -1);
+
+  ConnectionFileDescriptor read_conn{pipe.ReleaseReadFileDescriptor(),
+ /*owns_fd=*/true};
+  Communication write_comm("test");
+  write_comm.SetConnection(
+  std::make_unique(write_fd, /*owns_fd=*/true));
+
+  std::thread read_thread{[&read_conn]() {
+// Read using a smaller buffer to increase chances of partial write.
+char buf[128 * 1024];
+lldb::ConnectionStatus conn_status;
+
+do {
+  read_conn.Read(buf, sizeof(buf), std::chrono::seconds(1), conn_status,
+ nullptr);
+} while (conn_status != lldb::eConnectionStatusEndOfFile);
+  }};
+
+  // Write 1 MiB of data into the pipe.
+  lldb::ConnectionStatus conn_status;
+  Status error;
+  std::vector data(1024 * 1024, 0x80);
+  EXPECT_EQ(write_comm.WriteAll(data.data(), data.size(), conn_status, &error),
+data.size());
+  EXPECT_EQ(conn_status, lldb::eConnectionStatusSuccess);
+  EXPECT_FALSE(error.Fail());
+
+  // Close the write end in order to trigger EOF.
+  write_comm.Disconnect();
+  read_thread.join();
+}
+#endif
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -101,7 +101,7 @@
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
   ConnectionStatus status = eConnectionStatusSuccess;
   char ch = '+';
-  const size_t bytes_written = Write(&ch, 1, status, nullptr);
+  const size_t bytes_written = WriteAll(&ch, 1, status, nullptr);
   LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
   m_history.AddPacket(ch, GDBRemotePacket::ePacketTypeSend, bytes_written);
   return bytes_written;
@@ -111,7 +111,7 @@
   Log *log(ProcessGDBRemoteLog::GetLogIfAllCategoriesSet(GDBR_LOG_PACKETS));
   ConnectionStatus status = eConnectionStatusSuccess;
   char ch = '-';
-  const size_t bytes_written = Write(&ch, 1, status, nullptr);
+  const size_t bytes_written = WriteAll(&ch, 1, status, nullptr);
   LLDB_LOGF(log, "<%4" PRIu64 "> send packet: %c", (uint64_t)bytes_written, ch);
   m_history.AddPacket(ch, GDBRemotePacket::ePacketTypeSend, bytes_written);
   return bytes_written;
@@ -137,7 +137,7 @@
 ConnectionStatus status = eConnectionStatusSuccess;
 const char *packet_data = packet.data();
 const size_t packet_length = packet.size();
-size_t bytes_written = Write(packet_data, packet_length, status, nullptr);
+size_t bytes_written = WriteAll(packet_data, packet_length, status, nullptr);
 if (log) {
   size_t binary_start_offset = 0;
   if (strncmp(packet_data, "$vFile:pwrite:", strlen("$vFile:pwrite:")) ==
Index: lldb/source/Core/Communication.cpp
===
--- lldb/source/Core/Communication.cpp
+++ lldb/source/Core/Communication.cpp
@@ -189,6 +189,16 @@
   return 0;
 }
 
+size_t Communication::WriteAll(const void *src, size_t src_len,
+   ConnectionStatus &status, Status *error_ptr) {
+  size_t total_written = 0;
+  do
+total_written += Write(static_cast(src) +

[Lldb-commits] [lldb] 93c7ed8 - [lldb] Fix PlatformAppleSimulator for a458ef4f

2021-10-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-26T13:03:47+02:00
New Revision: 93c7ed8c3f8e2b2966e565758d0992ec1b07a11f

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

LOG: [lldb] Fix PlatformAppleSimulator for a458ef4f

Added: 


Modified: 
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
index c9c275caaeba..69692ddc77c4 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -529,8 +529,7 @@ static const char *g_ios_description = "iPhone simulator 
platform plug-in.";
 /// IPhone Simulator Plugin.
 struct PlatformiOSSimulator {
   static void Initialize() {
-PluginManager::RegisterPlugin(ConstString(g_ios_plugin_name),
-  g_ios_description,
+PluginManager::RegisterPlugin(g_ios_plugin_name, g_ios_description,
   PlatformiOSSimulator::CreateInstance);
   }
 
@@ -579,8 +578,7 @@ static const char *g_tvos_description = "tvOS simulator 
platform plug-in.";
 /// Apple TV Simulator Plugin.
 struct PlatformAppleTVSimulator {
   static void Initialize() {
-PluginManager::RegisterPlugin(ConstString(g_tvos_plugin_name),
-  g_tvos_description,
+PluginManager::RegisterPlugin(g_tvos_plugin_name, g_tvos_description,
   PlatformAppleTVSimulator::CreateInstance);
   }
 
@@ -621,8 +619,7 @@ static const char *g_watchos_description =
 /// Apple Watch Simulator Plugin.
 struct PlatformAppleWatchSimulator {
   static void Initialize() {
-PluginManager::RegisterPlugin(ConstString(g_watchos_plugin_name),
-  g_watchos_description,
+PluginManager::RegisterPlugin(g_watchos_plugin_name, g_watchos_description,
   PlatformAppleWatchSimulator::CreateInstance);
   }
 



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


[Lldb-commits] [lldb] 58d28b9 - [lldb] [lldb-gdbserver] Unify listen/connect code to use ConnectionFileDescriptor

2021-10-26 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-26T13:06:19+02:00
New Revision: 58d28b931f92f5ea2a6a01e088b794ee6ebd05e7

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

LOG: [lldb] [lldb-gdbserver] Unify listen/connect code to use 
ConnectionFileDescriptor

Unify the listen and connect code inside lldb-server to use
ConnectionFileDescriptor uniformly rather than a mix of it and Acceptor.
This involves:

- adding a function to map legacy values of host:port parameter
  (including legacy server URLs) into CFD-style URLs

- adding a callback to return "local socket id" (i.e. UNIX socket path
  or TCP port number) between listen() and accept() calls in CFD

- adding a "unix-abstract-accept" scheme to CFD

As an additional advantage, this permits lldb-server to accept any URL
known to CFD including the new serial:// scheme.  Effectively,
lldb-server can now listen on the serial port.  Tests for connecting
over a pty are added to test that.

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

Added: 
lldb/test/API/tools/lldb-server/TestPtyServer.py
lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerLLGSTest.cpp

Modified: 
lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
lldb/tools/lldb-server/lldb-gdbserver.cpp
lldb/unittests/Process/gdb-remote/CMakeLists.txt

Removed: 




diff  --git a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h 
b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
index 7500ec63707b..6d89fd710ab4 100644
--- a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
+++ b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
@@ -28,6 +28,9 @@ class SocketAddress;
 
 class ConnectionFileDescriptor : public Connection {
 public:
+  typedef llvm::function_ref
+  socket_id_callback_type;
+
   ConnectionFileDescriptor(bool child_processes_inherit = false);
 
   ConnectionFileDescriptor(int fd, bool owns_fd);
@@ -38,7 +41,12 @@ class ConnectionFileDescriptor : public Connection {
 
   bool IsConnected() const override;
 
-  lldb::ConnectionStatus Connect(llvm::StringRef s, Status *error_ptr) 
override;
+  lldb::ConnectionStatus Connect(llvm::StringRef url,
+ Status *error_ptr) override;
+
+  lldb::ConnectionStatus Connect(llvm::StringRef url,
+ socket_id_callback_type socket_id_callback,
+ Status *error_ptr);
 
   lldb::ConnectionStatus Disconnect(Status *error_ptr) override;
 
@@ -67,29 +75,51 @@ class ConnectionFileDescriptor : public Connection {
 
   void CloseCommandPipe();
 
-  lldb::ConnectionStatus SocketListenAndAccept(llvm::StringRef host_and_port,
-   Status *error_ptr);
+  lldb::ConnectionStatus
+  SocketListenAndAccept(llvm::StringRef host_and_port,
+socket_id_callback_type socket_id_callback,
+Status *error_ptr);
 
   lldb::ConnectionStatus ConnectTCP(llvm::StringRef host_and_port,
+socket_id_callback_type socket_id_callback,
+Status *error_ptr);
+
+  lldb::ConnectionStatus ConnectUDP(llvm::StringRef args,
+socket_id_callback_type socket_id_callback,
 Status *error_ptr);
 
-  lldb::ConnectionStatus ConnectUDP(llvm::StringRef args, Status *error_ptr);
+  lldb::ConnectionStatus
+  NamedSocketConnect(llvm::StringRef socket_name,
+ socket_id_callback_type socket_id_callback,
+ Status *error_ptr);
 
-  lldb::ConnectionStatus NamedSocketConnect(llvm::StringRef socket_name,
-Status *error_ptr);
+  lldb::ConnectionStatus
+  NamedSocketAccept(llvm::StringRef socket_name,
+socket_id_callback_type socket_id_callback,
+Status *error_ptr);
 
-  lldb::ConnectionStatus NamedSocketAccept(llvm::StringRef socket_name,
-   Status *error_ptr);
+  lldb::ConnectionStatus
+  UnixAbstractSocketAccept(llvm::StringRef socket_name,
+   socket_id_callback_type socket_id_callback,
+   Status *error_ptr);
 
-  lldb::ConnectionStatus UnixAbstractSocketConnect(llvm::StringRef socket_name,
-   Status *error_ptr);
+  lldb::ConnectionStatus
+  UnixAbstractSocketConnect(llvm::StringRef socket_name,
+   

[Lldb-commits] [PATCH] D111964: [lldb] [lldb-gdbserver] Unify listen/connect code to use ConnectionFileDescriptor

2021-10-26 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG58d28b931f92: [lldb] [lldb-gdbserver] Unify listen/connect 
code to use… (authored by mgorny).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D111964?vs=381918&id=382260#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111964

Files:
  lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h
  lldb/test/API/tools/lldb-server/TestPtyServer.py
  lldb/tools/lldb-server/lldb-gdbserver.cpp
  lldb/unittests/Process/gdb-remote/CMakeLists.txt
  lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerLLGSTest.cpp

Index: lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerLLGSTest.cpp
===
--- /dev/null
+++ lldb/unittests/Process/gdb-remote/GDBRemoteCommunicationServerLLGSTest.cpp
@@ -0,0 +1,63 @@
+//===-- GDBRemoteCommunicationServerLLGSTest.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "gtest/gtest.h"
+
+#include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h"
+
+using namespace lldb_private::process_gdb_remote;
+
+TEST(GDBRemoteCommunicationServerLLGSTest, LLGSArgToURL) {
+  // LLGS new-style URLs should be passed through (indepenently of
+  // --reverse-connect)
+  EXPECT_EQ(LLGSArgToURL("listen://127.0.0.1:1234", false),
+"listen://127.0.0.1:1234");
+  EXPECT_EQ(LLGSArgToURL("listen://127.0.0.1:1234", true),
+"listen://127.0.0.1:1234");
+  EXPECT_EQ(LLGSArgToURL("connect://127.0.0.1:1234", false),
+"connect://127.0.0.1:1234");
+  EXPECT_EQ(LLGSArgToURL("connect://127.0.0.1:1234", true),
+"connect://127.0.0.1:1234");
+
+  // LLGS legacy listen URLs should be converted if !reverse_connect
+  EXPECT_EQ(LLGSArgToURL("tcp://127.0.0.1:1234", false),
+"listen://127.0.0.1:1234");
+  EXPECT_EQ(LLGSArgToURL("unix:///tmp/foo", false), "unix-accept:///tmp/foo");
+  EXPECT_EQ(LLGSArgToURL("unix-abstract://foo", false),
+"unix-abstract-accept://foo");
+
+  // LLGS listen host:port pairs should be converted to listen://
+  EXPECT_EQ(LLGSArgToURL("127.0.0.1:1234", false), "listen://127.0.0.1:1234");
+  EXPECT_EQ(LLGSArgToURL("[::1]:1234", false), "listen://[::1]:1234");
+  EXPECT_EQ(LLGSArgToURL("[[::1]:1234]", false), "listen://[[::1]:1234]");
+  EXPECT_EQ(LLGSArgToURL("localhost:1234", false), "listen://localhost:1234");
+  EXPECT_EQ(LLGSArgToURL("*:1234", false), "listen://*:1234");
+
+  // LLGS listen :port special-case should be converted to listen://
+  EXPECT_EQ(LLGSArgToURL(":1234", false), "listen://localhost:1234");
+
+  // LLGS listen UNIX sockets should be converted to unix-accept://
+  EXPECT_EQ(LLGSArgToURL("/tmp/foo", false), "unix-accept:///tmp/foo");
+  EXPECT_EQ(LLGSArgToURL("127.0.0.1", false), "unix-accept://127.0.0.1");
+  EXPECT_EQ(LLGSArgToURL("[::1]", false), "unix-accept://[::1]");
+  EXPECT_EQ(LLGSArgToURL("localhost", false), "unix-accept://localhost");
+  EXPECT_EQ(LLGSArgToURL(":frobnicate", false), "unix-accept://:frobnicate");
+
+  // LLGS reverse connect host:port pairs should be converted to connect://
+  EXPECT_EQ(LLGSArgToURL("127.0.0.1:1234", true), "connect://127.0.0.1:1234");
+  EXPECT_EQ(LLGSArgToURL("[::1]:1234", true), "connect://[::1]:1234");
+  EXPECT_EQ(LLGSArgToURL("[[::1]:1234]", true), "connect://[[::1]:1234]");
+  EXPECT_EQ(LLGSArgToURL("localhost:1234", true), "connect://localhost:1234");
+
+  // with LLGS reverse connect, anything else goes as unix-connect://
+  EXPECT_EQ(LLGSArgToURL("/tmp/foo", true), "unix-connect:///tmp/foo");
+  EXPECT_EQ(LLGSArgToURL("127.0.0.1", true), "unix-connect://127.0.0.1");
+  EXPECT_EQ(LLGSArgToURL("[::1]", true), "unix-connect://[::1]");
+  EXPECT_EQ(LLGSArgToURL("localhost", true), "unix-connect://localhost");
+  EXPECT_EQ(LLGSArgToURL(":frobnicate", true), "unix-connect://:frobnicate");
+}
Index: lldb/unittests/Process/gdb-remote/CMakeLists.txt
===
--- lldb/unittests/Process/gdb-remote/CMakeLists.txt
+++ lldb/unittests/Process/gdb-remote/CMakeLists.txt
@@ -1,6 +1,7 @@
 add_lldb_unittest(ProcessGdbRemoteTests
   GDBRemoteClientBaseTest.cpp
   GDBRemoteCommunicationClientTest.cpp
+  GDBRemoteCommunicationServerLLGSTest.cpp
   GDBRemoteCommunicationServerTest.cpp
   GDBRemoteCommunicationTest.cpp
   GDB

[Lldb-commits] [lldb] 4373f35 - [lldb] [Host] Move port predicate-related logic to gdb-remote

2021-10-26 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-26T13:53:08+02:00
New Revision: 4373f3595f8e37f6183d9880ee5b4eb59cba3852

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

LOG: [lldb] [Host] Move port predicate-related logic to gdb-remote

Remove the port predicate from Socket and ConnectionFileDescriptor,
and move it to gdb-remote.  It is specifically relevant to the threading
used inside gdb-remote and with the new port callback API, we can
reliably move it there.  While at it, switch from the custom Predicate
to std::promise/std::future.

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

Added: 


Modified: 
lldb/include/lldb/Host/Socket.h
lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
lldb/source/Host/common/Socket.cpp
lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
lldb/unittests/Host/SocketTest.cpp
lldb/unittests/Host/SocketTestUtilities.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h
index 12ddc11be4f8..780c6e6a 100644
--- a/lldb/include/lldb/Host/Socket.h
+++ b/lldb/include/lldb/Host/Socket.h
@@ -16,7 +16,6 @@
 
 #include "lldb/Host/SocketAddress.h"
 #include "lldb/Utility/IOObject.h"
-#include "lldb/Utility/Predicate.h"
 #include "lldb/Utility/Status.h"
 
 #ifdef _WIN32
@@ -68,7 +67,7 @@ class Socket : public IOObject {
   // the socket after it is initialized, but before entering a blocking accept.
   static llvm::Expected>
   TcpListen(llvm::StringRef host_and_port, bool child_processes_inherit,
-Predicate *predicate, int backlog = 5);
+int backlog = 5);
 
   static llvm::Expected>
   TcpConnect(llvm::StringRef host_and_port, bool child_processes_inherit);

diff  --git a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h 
b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
index 6d89fd710ab4..12eab5fc8ae8 100644
--- a/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
+++ b/lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
@@ -18,7 +18,6 @@
 #include "lldb/Host/Pipe.h"
 #include "lldb/Utility/Connection.h"
 #include "lldb/Utility/IOObject.h"
-#include "lldb/Utility/Predicate.h"
 
 namespace lldb_private {
 
@@ -65,8 +64,6 @@ class ConnectionFileDescriptor : public Connection {
 
   lldb::IOObjectSP GetReadObject() override { return m_io_sp; }
 
-  uint16_t GetListeningPort(const Timeout &timeout);
-
   bool GetChildProcessesInherit() const;
   void SetChildProcessesInherit(bool child_processes_inherit);
 
@@ -123,11 +120,6 @@ class ConnectionFileDescriptor : public Connection {
 
   lldb::IOObjectSP m_io_sp;
 
-  Predicate
-  m_port_predicate; // Used when binding to port zero to wait for the 
thread
-// that creates the socket, binds and listens to
-// resolve the port number.
-
   Pipe m_pipe;
   std::recursive_mutex m_mutex;
   std::atomic m_shutting_down; // This marks that we are shutting down so

diff  --git a/lldb/source/Host/common/Socket.cpp 
b/lldb/source/Host/common/Socket.cpp
index 9ca26d911c25..1eaa69532592 100644
--- a/lldb/source/Host/common/Socket.cpp
+++ b/lldb/source/Host/common/Socket.cpp
@@ -163,7 +163,7 @@ Socket::TcpConnect(llvm::StringRef host_and_port,
 
 llvm::Expected>
 Socket::TcpListen(llvm::StringRef host_and_port, bool child_processes_inherit,
-  Predicate *predicate, int backlog) {
+  int backlog) {
   Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION));
   LLDB_LOG(log, "host_and_port = {0}", host_and_port);
 
@@ -187,13 +187,6 @@ Socket::TcpListen(llvm::StringRef host_and_port, bool 
child_processes_inherit,
   if (port == 0)
 port = listen_socket->GetLocalPortNumber();
 
-  // Set the port predicate since when doing a listen://: it
-  // often needs to accept the incoming connection which is a blocking system
-  // call. Allowing access to the bound port using a predicate allows us to
-  // wait for the port predicate to be set to a non-zero value from another
-  // thread in an efficient manor.
-  if (predicate)
-predicate->SetValue(port, eBroadcastAlways);
   return std::move(listen_socket);
 }
 

diff  --git a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp 
b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
index fdbf660a1527..1c3de966916a 100644
--- a/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ b/lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -622,10 +622,9 @@ ConnectionStatus 
ConnectionFileDescriptor::SocketListenAndAccept(
 Status *error_ptr) {
   if (error_ptr)
 *error_p

[Lldb-commits] [PATCH] D112357: [lldb] [Host] Move port predicate-related logic to gdb-remote

2021-10-26 Thread Michał Górny via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4373f3595f8e: [lldb] [Host] Move port predicate-related 
logic to gdb-remote (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112357

Files:
  lldb/include/lldb/Host/Socket.h
  lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
  lldb/source/Host/common/Socket.cpp
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
  lldb/unittests/Host/SocketTest.cpp
  lldb/unittests/Host/SocketTestUtilities.cpp

Index: lldb/unittests/Host/SocketTestUtilities.cpp
===
--- lldb/unittests/Host/SocketTestUtilities.cpp
+++ lldb/unittests/Host/SocketTestUtilities.cpp
@@ -93,7 +93,7 @@
 
 static bool CheckIPSupport(llvm::StringRef Proto, llvm::StringRef Addr) {
   llvm::Expected> Sock = Socket::TcpListen(
-  Addr, /*child_processes_inherit=*/false, /*predicate=*/nullptr);
+  Addr, /*child_processes_inherit=*/false);
   if (Sock)
 return true;
   llvm::Error Err = Sock.takeError();
Index: lldb/unittests/Host/SocketTest.cpp
===
--- lldb/unittests/Host/SocketTest.cpp
+++ lldb/unittests/Host/SocketTest.cpp
@@ -154,10 +154,8 @@
 TEST_P(SocketTest, TCPListen0GetPort) {
   if (!HostSupportsIPv4())
 return;
-  Predicate port_predicate;
-  port_predicate.SetValue(0, eBroadcastNever);
   llvm::Expected> sock =
-  Socket::TcpListen("10.10.12.3:0", false, &port_predicate);
+  Socket::TcpListen("10.10.12.3:0", false);
   ASSERT_THAT_EXPECTED(sock, llvm::Succeeded());
   ASSERT_TRUE(sock.get()->IsValid());
   EXPECT_NE(sock.get()->GetLocalPortNumber(), 0);
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.h
@@ -12,6 +12,7 @@
 #include "GDBRemoteCommunicationHistory.h"
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -243,6 +244,8 @@
   std::mutex m_packet_queue_mutex; // Mutex for accessing queue
   std::condition_variable
   m_condition_queue_not_empty; // Condition variable to wait for packets
+  // Promise used to grab the port number from listening thread
+  std::promise m_port_promise;
 
   HostThread m_listen_thread;
   std::string m_listen_url;
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -893,8 +893,13 @@
 
   if (connection) {
 // Do the listen on another thread so we can continue on...
-if (connection->Connect(comm->m_listen_url.c_str(), &error) !=
-eConnectionStatusSuccess)
+if (connection->Connect(
+comm->m_listen_url.c_str(), [comm](llvm::StringRef port_str) {
+  uint16_t port = 0;
+  llvm::to_integer(port_str, port, 10);
+  comm->m_port_promise.set_value(port);
+},
+&error) != eConnectionStatusSuccess)
   comm->SetConnection(nullptr);
   }
   return {};
@@ -1056,10 +1061,12 @@
   return error;
 }
 
-ConnectionFileDescriptor *connection =
-(ConnectionFileDescriptor *)GetConnection();
 // Wait for 10 seconds to resolve the bound port
-uint16_t port_ = connection->GetListeningPort(std::chrono::seconds(10));
+std::future port_future = m_port_promise.get_future();
+uint16_t port_ = port_future.wait_for(std::chrono::seconds(10)) ==
+ std::future_status::ready
+ ? port_future.get()
+ : 0;
 if (port_ > 0) {
   char port_cstr[32];
   snprintf(port_cstr, sizeof(port_cstr), "127.0.0.1:%i", port_);
Index: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
===
--- lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -622,10 +622,9 @@
 Status *error_ptr) {
   if (error_ptr)
 *error_ptr = Status();
-  m_port_predicate.SetValue(0, eBroadcastNever);
 
   llvm::Expected> listening_socket =
-  Socket::TcpListen(s, m_child_processes_inherit, &m_port_predicate);
+  Socket::TcpListen(s, m_child_processes_inherit);
   if (!listening_socket) {
 if (error_ptr)
   *error_ptr = lis

[Lldb-commits] [PATCH] D112069: [lldb][AArch64] Add UnwindPlan for Linux sigreturn

2021-10-26 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 382287.
DavidSpickett added a comment.

Set ValidAtAllInstructions.

Move building unwind plan into PlatformLinux and add a platform method
to lookup unwind plans for signal handlers. I'm still checking architecture
in PlatformLinux but it does move the code out of Symbol.

The only per arch thing on lldb's side is Architecture plugins but they're
not meant to know about operating system. So it seems like a reasonable
compromise to put it in PlatformLinux.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112069

Files:
  lldb/include/lldb/Target/Platform.h
  lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
  lldb/source/Plugins/Platform/Linux/PlatformLinux.h
  lldb/source/Target/RegisterContextUnwind.cpp
  lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py

Index: lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
===
--- lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
+++ lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
@@ -16,8 +16,6 @@
 NO_DEBUG_INFO_TESTCASE = True
 
 @skipIfWindows  # signals do not exist on Windows
-# Fails on Ubuntu Focal
-@skipIf(archs=["aarch64"], oslist=["linux"])
 @expectedFailureNetBSD
 def test_inferior_handle_sigabrt(self):
 """Inferior calls abort() and handles the resultant SIGABRT.
@@ -47,6 +45,9 @@
 self.assertEqual(thread.GetStopReasonDataAtIndex(0),
  signo, "The stop signal should be SIGABRT")
 
+# Save the backtrace frames to compare to the handler backtrace later.
+signal_frames = thread.get_thread_frames()
+
 # Continue to breakpoint in abort handler
 bkpt = target.FindBreakpointByID(
 lldbutil.run_break_set_by_source_regexp(self, "Set a breakpoint here"))
@@ -58,13 +59,21 @@
 frame = thread.GetFrameAtIndex(0)
 self.assertEqual(frame.GetDisplayFunctionName(), "handler", "Unexpected break?")
 
+handler_frames = thread.get_thread_frames()
+
 # Expect that unwinding should find 'abort_caller'
-foundFoo = False
-for frame in thread:
+found_caller = False
+for frame in handler_frames:
 if frame.GetDisplayFunctionName() == "abort_caller":
-foundFoo = True
+found_caller = True
+break
+
+self.assertTrue(found_caller, "Unwinding did not find func that called abort")
 
-self.assertTrue(foundFoo, "Unwinding did not find func that called abort")
+# Check that frames present in both backtraces have the same addresses.
+# The signal handler backtrace has extra frames at the start.
+self.assertEqual(signal_frames, handler_frames[-len(signal_frames):],
+  "Common frames for signal and signal handler backtrace do not match")
 
 # Continue until we exit.
 process.Continue()
Index: lldb/source/Target/RegisterContextUnwind.cpp
===
--- lldb/source/Target/RegisterContextUnwind.cpp
+++ lldb/source/Target/RegisterContextUnwind.cpp
@@ -900,6 +900,17 @@
   // unwind out of sigtramp.
   if (m_frame_type == eTrapHandlerFrame && process) {
 m_fast_unwind_plan_sp.reset();
+
+if (m_sym_ctx_valid) {
+  lldb::PlatformSP platform = process->GetTarget().GetPlatform();
+  unwind_plan_sp = platform->GetTrapHandlerUnwindPlan(
+  process->GetTarget().GetArchitecture().GetMachine(),
+  GetSymbolOrFunctionName(m_sym_ctx));
+
+  if (unwind_plan_sp)
+return unwind_plan_sp;
+}
+
 unwind_plan_sp =
 func_unwinders_sp->GetEHFrameUnwindPlan(process->GetTarget());
 if (!unwind_plan_sp)
Index: lldb/source/Plugins/Platform/Linux/PlatformLinux.h
===
--- lldb/source/Plugins/Platform/Linux/PlatformLinux.h
+++ lldb/source/Plugins/Platform/Linux/PlatformLinux.h
@@ -50,6 +50,9 @@
 
   void CalculateTrapHandlerSymbolNames() override;
 
+  lldb::UnwindPlanSP GetTrapHandlerUnwindPlan(llvm::Triple::ArchType machine,
+  ConstString name) override;
+
   MmapArgList GetMmapArgumentList(const ArchSpec &arch, lldb::addr_t addr,
   lldb::addr_t length, unsigned prot,
   unsigned flags, lldb::addr_t fd,
Index: lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
===
--- lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -14,9 +14,11 @@
 #include 
 #endif
 
+#include "Utility/ARM64_DWARF_Registers.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/PluginM

[Lldb-commits] [PATCH] D112069: [lldb][AArch64] Add UnwindPlan for Linux sigreturn

2021-10-26 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp:258
+  UnwindPlanSP unwind_plan_sp;
+  if (name != "__kernel_rt_sigreturn")
+return unwind_plan_sp;

PlatformLinux lists 3 handlers:
* _sigtramp
* __kernel_rt_sigreturn
* __restore_rt

I think the first 2 are the same for AArch64 due to this line in the kernel:
VDSO_sigtramp= __kernel_rt_sigreturn;

The third is for real time signals which I'm only just learning about. So I'll 
see what that's about but probably not relevant for this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112069

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


[Lldb-commits] [PATCH] D112537: Set synthetic children. I have dove the generic tests for set. I have considered Libcxx tests as the one covering all the edge cases (including pointer and reference va

2021-10-26 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan created this revision.
Herald added a subscriber: mgorny.
danilashtefan requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

...properties. However, I have decided to vhange them only when applying the 
set summary provider, and change them back to their previous state, not to 
alter other summary providers' behaviour


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112537

Files:
  lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp
@@ -0,0 +1,55 @@
+#include 
+#include 
+
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1) {
+  if (arg < 0)
+arg = 0;
+  if (!arg)
+arg = 1;
+  g_the_foo += arg;
+  return g_the_foo;
+}
+
+void by_ref_and_ptr(std::set &ref, std::set *ptr) {
+  // Stop here to check by ref and ptr
+  return;
+}
+
+int main() {
+  std::set ii;
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(0);
+  ii.insert(1);
+  ii.insert(2);
+  ii.insert(3);
+  ii.insert(4);
+  ii.insert(5);
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(6);
+  thefoo_rw(1); // Set break point at this line.
+
+  by_ref_and_ptr(ii, &ii);
+
+  ii.clear();
+  thefoo_rw(1); // Set break point at this line.
+
+  std::set ss;
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("a");
+  ss.insert("a very long string is right here");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("b");
+  ss.insert("c");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.erase("b");
+  thefoo_rw(1); // Set break point at this line.
+
+  return 0;
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
@@ -0,0 +1,157 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+USE_LIBCPP = "USE_LIBCPP"
+
+class LibcxxSetDataFormatterTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.namespace = 'std'
+
+def getVariableType(self, name):
+var = self.frame().FindVariable(name)
+self.assertTrue(var.IsValid())
+return var.GetType().GetDisplayTypeName()
+
+def check_ii(self, var_name):
+""" This checks the value of the bitset stored in ii at the call to by_ref_and_ptr.
+We use this to make sure we get the same values for ii when we look at the object
+directly, and when we look at a reference to the object. """
+self.expect(
+"frame variable " + var_name,
+substrs=["size=7",
+ "[2] = 2",
+ "[3] = 3",
+ "[6] = 6"])
+self.expect("frame variable " + var_name + "[2]", substrs=[" = 2"])
+self.expect(
+"p " + var_name,
+substrs=[
+"size=7",
+"[2] = 2",
+"[3] = 3",
+"[6] = 6"])
+
+
+def do_test_with_run_command(self,stdlib_type):
+"""Test that that file and class static variables display correctly."""
+self.build(dictionary={stdlib_type: "1"})
+(self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "Set break point at this line.", lldb.SBFileSpec("main.cpp", False))
+
+# This is the function to remove the custom formats in order to have a
+# clean slate for the next test case.
+def cleanup():
+self.runCmd('type format clear', check=False)
+self.runCmd('type summary clear', check=False)
+self.runCmd('type filter clear', check=False)
+self.runCmd('type synth clear', check=False)
+self.runCmd(
+"settings set target.max-children-count 256",
+check=False)
+
+# Execute the cleanup function during test case tear down.
+self.addTearDownHook(cleanup)
+
+ii_type = self.getVariableType("ii")
+self.assertT

[Lldb-commits] [PATCH] D112180: Libcpp bitset syntethic children and tests

2021-10-26 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan updated this revision to Diff 382325.
danilashtefan added a comment.

Minor corrections


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112180

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp
@@ -0,0 +1,55 @@
+#include 
+#include 
+
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1) {
+  if (arg < 0)
+arg = 0;
+  if (!arg)
+arg = 1;
+  g_the_foo += arg;
+  return g_the_foo;
+}
+
+void by_ref_and_ptr(std::set &ref, std::set *ptr) {
+  // Stop here to check by ref and ptr
+  return;
+}
+
+int main() {
+  std::set ii;
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(0);
+  ii.insert(1);
+  ii.insert(2);
+  ii.insert(3);
+  ii.insert(4);
+  ii.insert(5);
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(6);
+  thefoo_rw(1); // Set break point at this line.
+
+  by_ref_and_ptr(ii, &ii);
+
+  ii.clear();
+  thefoo_rw(1); // Set break point at this line.
+
+  std::set ss;
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("a");
+  ss.insert("a very long string is right here");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("b");
+  ss.insert("c");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.erase("b");
+  thefoo_rw(1); // Set break point at this line.
+
+  return 0;
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
@@ -0,0 +1,157 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+USE_LIBCPP = "USE_LIBCPP"
+
+class LibcxxSetDataFormatterTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.namespace = 'std'
+
+def getVariableType(self, name):
+var = self.frame().FindVariable(name)
+self.assertTrue(var.IsValid())
+return var.GetType().GetDisplayTypeName()
+
+def check_ii(self, var_name):
+""" This checks the value of the bitset stored in ii at the call to by_ref_and_ptr.
+We use this to make sure we get the same values for ii when we look at the object
+directly, and when we look at a reference to the object. """
+self.expect(
+"frame variable " + var_name,
+substrs=["size=7",
+ "[2] = 2",
+ "[3] = 3",
+ "[6] = 6"])
+self.expect("frame variable " + var_name + "[2]", substrs=[" = 2"])
+self.expect(
+"p " + var_name,
+substrs=[
+"size=7",
+"[2] = 2",
+"[3] = 3",
+"[6] = 6"])
+
+
+def do_test_with_run_command(self,stdlib_type):
+"""Test that that file and class static variables display correctly."""
+self.build(dictionary={stdlib_type: "1"})
+(self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "Set break point at this line.", lldb.SBFileSpec("main.cpp", False))
+
+# This is the function to remove the custom formats in order to have a
+# clean slate for the next test case.
+def cleanup():
+self.runCmd('type format clear', check=False)
+self.runCmd('type summary clear', check=False)
+self.runCmd('type filter clear', check=False)
+self.runCmd('type synth clear', check=False)
+self.runCmd(
+"settings set target.max-children-count 256",
+check=False)
+
+# Execute the cleanup function during test case tear down.
+self.addTearDownHook(cleanup)
+
+ii_type = self.getVariableType("ii")
+self.assertTrue(ii_type.startswith(self.namespace + "::set"),
+"Type: " + ii_type)
+
+self.expect("frame variable ii", substrs=["size=0", "{}"])
+lldbutil.continue_to_breakpoint(process, bkpt)
+self.expect(
+"frame variable ii",
+substrs=["size=6",
+  

[Lldb-commits] [PATCH] D112537: Set synthetic children. I have dove the generic tests for set. I have considered Libcxx tests as the one covering all the edge cases (including pointer and reference va

2021-10-26 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan updated this revision to Diff 382330.
danilashtefan added a comment.

Set synthetic children


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112537

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp
@@ -0,0 +1,55 @@
+#include 
+#include 
+
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1) {
+  if (arg < 0)
+arg = 0;
+  if (!arg)
+arg = 1;
+  g_the_foo += arg;
+  return g_the_foo;
+}
+
+void by_ref_and_ptr(std::set &ref, std::set *ptr) {
+  // Stop here to check by ref and ptr
+  return;
+}
+
+int main() {
+  std::set ii;
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(0);
+  ii.insert(1);
+  ii.insert(2);
+  ii.insert(3);
+  ii.insert(4);
+  ii.insert(5);
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(6);
+  thefoo_rw(1); // Set break point at this line.
+
+  by_ref_and_ptr(ii, &ii);
+
+  ii.clear();
+  thefoo_rw(1); // Set break point at this line.
+
+  std::set ss;
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("a");
+  ss.insert("a very long string is right here");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("b");
+  ss.insert("c");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.erase("b");
+  thefoo_rw(1); // Set break point at this line.
+
+  return 0;
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
@@ -0,0 +1,157 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+USE_LIBCPP = "USE_LIBCPP"
+
+class LibcxxSetDataFormatterTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.namespace = 'std'
+
+def getVariableType(self, name):
+var = self.frame().FindVariable(name)
+self.assertTrue(var.IsValid())
+return var.GetType().GetDisplayTypeName()
+
+def check_ii(self, var_name):
+""" This checks the value of the bitset stored in ii at the call to by_ref_and_ptr.
+We use this to make sure we get the same values for ii when we look at the object
+directly, and when we look at a reference to the object. """
+self.expect(
+"frame variable " + var_name,
+substrs=["size=7",
+ "[2] = 2",
+ "[3] = 3",
+ "[6] = 6"])
+self.expect("frame variable " + var_name + "[2]", substrs=[" = 2"])
+self.expect(
+"p " + var_name,
+substrs=[
+"size=7",
+"[2] = 2",
+"[3] = 3",
+"[6] = 6"])
+
+
+def do_test_with_run_command(self,stdlib_type):
+"""Test that that file and class static variables display correctly."""
+self.build(dictionary={stdlib_type: "1"})
+(self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "Set break point at this line.", lldb.SBFileSpec("main.cpp", False))
+
+# This is the function to remove the custom formats in order to have a
+# clean slate for the next test case.
+def cleanup():
+self.runCmd('type format clear', check=False)
+self.runCmd('type summary clear', check=False)
+self.runCmd('type filter clear', check=False)
+self.runCmd('type synth clear', check=False)
+self.runCmd(
+"settings set target.max-children-count 256",
+check=False)
+
+# Execute the cleanup function during test case tear down.
+self.addTearDownHook(cleanup)
+
+ii_type = self.getVariableType("ii")
+self.assertTrue(ii_type.startswith(self.namespace + "::set"),
+"Type: " + ii_type)
+
+self.expect("frame variable ii", substrs=["size=0", "{}"])
+lldbutil.continue_to_breakpoint(process, bkpt)
+self.expect(
+"frame variable ii",
+substrs=["size=6",
+ 

[Lldb-commits] [PATCH] D112537: Set synthetic children. I have dove the generic tests for set. I have considered Libcxx tests as the one covering all the edge cases (including pointer and reference va

2021-10-26 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan updated this revision to Diff 382336.
danilashtefan added a comment.

Set synthetic child


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112537

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp
@@ -0,0 +1,55 @@
+#include 
+#include 
+
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1) {
+  if (arg < 0)
+arg = 0;
+  if (!arg)
+arg = 1;
+  g_the_foo += arg;
+  return g_the_foo;
+}
+
+void by_ref_and_ptr(std::set &ref, std::set *ptr) {
+  // Stop here to check by ref and ptr
+  return;
+}
+
+int main() {
+  std::set ii;
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(0);
+  ii.insert(1);
+  ii.insert(2);
+  ii.insert(3);
+  ii.insert(4);
+  ii.insert(5);
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(6);
+  thefoo_rw(1); // Set break point at this line.
+
+  by_ref_and_ptr(ii, &ii);
+
+  ii.clear();
+  thefoo_rw(1); // Set break point at this line.
+
+  std::set ss;
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("a");
+  ss.insert("a very long string is right here");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("b");
+  ss.insert("c");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.erase("b");
+  thefoo_rw(1); // Set break point at this line.
+
+  return 0;
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
@@ -0,0 +1,157 @@
+"""
+Test lldb data formatter subsystem.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+USE_LIBCPP = "USE_LIBCPP"
+
+class LibcxxSetDataFormatterTestCase(TestBase):
+
+mydir = TestBase.compute_mydir(__file__)
+
+def setUp(self):
+TestBase.setUp(self)
+self.namespace = 'std'
+
+def getVariableType(self, name):
+var = self.frame().FindVariable(name)
+self.assertTrue(var.IsValid())
+return var.GetType().GetDisplayTypeName()
+
+def check_ii(self, var_name):
+""" This checks the value of the bitset stored in ii at the call to by_ref_and_ptr.
+We use this to make sure we get the same values for ii when we look at the object
+directly, and when we look at a reference to the object. """
+self.expect(
+"frame variable " + var_name,
+substrs=["size=7",
+ "[2] = 2",
+ "[3] = 3",
+ "[6] = 6"])
+self.expect("frame variable " + var_name + "[2]", substrs=[" = 2"])
+self.expect(
+"p " + var_name,
+substrs=[
+"size=7",
+"[2] = 2",
+"[3] = 3",
+"[6] = 6"])
+
+
+def do_test_with_run_command(self,stdlib_type):
+"""Test that that file and class static variables display correctly."""
+self.build(dictionary={stdlib_type: "1"})
+(self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint(
+self, "Set break point at this line.", lldb.SBFileSpec("main.cpp", False))
+
+# This is the function to remove the custom formats in order to have a
+# clean slate for the next test case.
+def cleanup():
+self.runCmd('type format clear', check=False)
+self.runCmd('type summary clear', check=False)
+self.runCmd('type filter clear', check=False)
+self.runCmd('type synth clear', check=False)
+self.runCmd(
+"settings set target.max-children-count 256",
+check=False)
+
+# Execute the cleanup function during test case tear down.
+self.addTearDownHook(cleanup)
+
+ii_type = self.getVariableType("ii")
+self.assertTrue(ii_type.startswith(self.namespace + "::set"),
+"Type: " + ii_type)
+
+self.expect("frame variable ii", substrs=["size=0", "{}"])
+lldbutil.continue_to_breakpoint(process, bkpt)
+self.expect(
+"frame variable ii",
+substrs=["size=6",
+

[Lldb-commits] [PATCH] D112537: Set synthetic children

2021-10-26 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan updated this revision to Diff 382348.
danilashtefan added a comment.

Deleted libcxx tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112537

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/TestDataFormatterLibcxxSet.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/set/main.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-#include 
-#include 
-
-int g_the_foo = 0;
-
-int thefoo_rw(int arg = 1)
-{
-	if (arg < 0)
-		arg = 0;
-	if (!arg)
-		arg = 1;
-	g_the_foo += arg;
-	return g_the_foo;
-}
-
-void by_ref_and_ptr(std::set &ref, std::set *ptr)
-{
-// Stop here to check by ref and ptr
-return;
-} 
-
-int main()
-{
-std::set ii;
-thefoo_rw(1);  // Set break point at this line.
-	
-	ii.insert(0);
-	ii.insert(1);
-	ii.insert(2);
-	ii.insert(3);
-	ii.insert(4);
-	ii.insert(5);
-thefoo_rw(1);  // Set break point at this line.
-
-	ii.insert(6);
-	thefoo_rw(1);  // Set break point at this line.
-
-by_ref_and_ptr(ii, &ii);
-
-	ii.clear();
-	thefoo_rw(1);  // Set break point at this line.
-
-	std::set ss;
-	thefoo_rw(1);  // Set break point at this line.
-
-	ss.insert("a");
-	ss.insert("a very long string is right here");
-	thefoo_rw(1);  // Set break point at this line.
-
-	ss.insert("b");
-	ss.insert("c");
-	thefoo_rw(1);  // Set break point at this line.
-	
-	ss.erase("b");
-	thefoo_rw(1);  // Set break point at this line.
-
-return 0;
-}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/main.cpp
@@ -0,0 +1,55 @@
+#include 
+#include 
+
+int g_the_foo = 0;
+
+int thefoo_rw(int arg = 1) {
+  if (arg < 0)
+arg = 0;
+  if (!arg)
+arg = 1;
+  g_the_foo += arg;
+  return g_the_foo;
+}
+
+void by_ref_and_ptr(std::set &ref, std::set *ptr) {
+  // Stop here to check by ref and ptr
+  return;
+}
+
+int main() {
+  std::set ii;
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(0);
+  ii.insert(1);
+  ii.insert(2);
+  ii.insert(3);
+  ii.insert(4);
+  ii.insert(5);
+  thefoo_rw(1); // Set break point at this line.
+
+  ii.insert(6);
+  thefoo_rw(1); // Set break point at this line.
+
+  by_ref_and_ptr(ii, &ii);
+
+  ii.clear();
+  thefoo_rw(1); // Set break point at this line.
+
+  std::set ss;
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("a");
+  ss.insert("a very long string is right here");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.insert("b");
+  ss.insert("c");
+  thefoo_rw(1); // Set break point at this line.
+
+  ss.erase("b");
+  thefoo_rw(1); // Set break point at this line.
+
+  return 0;
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py
@@ -9,6 +9,8 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+USE_LIBCPP = "USE_LIBCPP"
 
 class LibcxxSetDataFormatterTestCase(TestBase):
 
@@ -42,10 +44,10 @@
 "[3] = 3",
 "[6] = 6"])
 
-@add_test_categories(["libc++"])
-def test_with_run_command(self):
+
+def do_test_with_run_command(self,stdlib_type):
 """Test that that file and class static variables display correctly."""
-self.build()
+self.build(dictionary={stdlib_type: "1"})
 (self.target, process, _, bkpt) = lldbutil.run_to_source_breakpoint(
 self, "Set break point at this line.", lldb.SBFileSpec("main.cpp", False))
 
@@ -121,8 +123,16 @@
  '[1] = "a very long string is right here"',
  '[2] = "c"'])
 
+@add_test_categories(["libstdcxx"])  
+def test_with_run_command_libstdcpp(self):
+self.do_test_with_run_command(USE_LIBSTDCPP)
+
 @add_test_c

[Lldb-commits] [PATCH] D112069: [lldb][AArch64] Add UnwindPlan for Linux sigreturn

2021-10-26 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 382354.
DavidSpickett added a comment.

Set SP not FP based on the sigcontext.

Before, the SP of the frame before sigcontext would be incorrect.
(noticed while testing alt signal stacks)

This was already done in the libunwind change but I got them mixed up.

I'll come up with some addition to the tests to check this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112069

Files:
  lldb/include/lldb/Target/Platform.h
  lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
  lldb/source/Plugins/Platform/Linux/PlatformLinux.h
  lldb/source/Target/RegisterContextUnwind.cpp
  lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py

Index: lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
===
--- lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
+++ lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
@@ -16,8 +16,6 @@
 NO_DEBUG_INFO_TESTCASE = True
 
 @skipIfWindows  # signals do not exist on Windows
-# Fails on Ubuntu Focal
-@skipIf(archs=["aarch64"], oslist=["linux"])
 @expectedFailureNetBSD
 def test_inferior_handle_sigabrt(self):
 """Inferior calls abort() and handles the resultant SIGABRT.
@@ -47,6 +45,9 @@
 self.assertEqual(thread.GetStopReasonDataAtIndex(0),
  signo, "The stop signal should be SIGABRT")
 
+# Save the backtrace frames to compare to the handler backtrace later.
+signal_frames = thread.get_thread_frames()
+
 # Continue to breakpoint in abort handler
 bkpt = target.FindBreakpointByID(
 lldbutil.run_break_set_by_source_regexp(self, "Set a breakpoint here"))
@@ -58,13 +59,21 @@
 frame = thread.GetFrameAtIndex(0)
 self.assertEqual(frame.GetDisplayFunctionName(), "handler", "Unexpected break?")
 
+handler_frames = thread.get_thread_frames()
+
 # Expect that unwinding should find 'abort_caller'
-foundFoo = False
-for frame in thread:
+found_caller = False
+for frame in handler_frames:
 if frame.GetDisplayFunctionName() == "abort_caller":
-foundFoo = True
+found_caller = True
+break
+
+self.assertTrue(found_caller, "Unwinding did not find func that called abort")
 
-self.assertTrue(foundFoo, "Unwinding did not find func that called abort")
+# Check that frames present in both backtraces have the same addresses.
+# The signal handler backtrace has extra frames at the start.
+self.assertEqual(signal_frames, handler_frames[-len(signal_frames):],
+  "Common frames for signal and signal handler backtrace do not match")
 
 # Continue until we exit.
 process.Continue()
Index: lldb/source/Target/RegisterContextUnwind.cpp
===
--- lldb/source/Target/RegisterContextUnwind.cpp
+++ lldb/source/Target/RegisterContextUnwind.cpp
@@ -900,6 +900,17 @@
   // unwind out of sigtramp.
   if (m_frame_type == eTrapHandlerFrame && process) {
 m_fast_unwind_plan_sp.reset();
+
+if (m_sym_ctx_valid) {
+  lldb::PlatformSP platform = process->GetTarget().GetPlatform();
+  unwind_plan_sp = platform->GetTrapHandlerUnwindPlan(
+  process->GetTarget().GetArchitecture().GetMachine(),
+  GetSymbolOrFunctionName(m_sym_ctx));
+
+  if (unwind_plan_sp)
+return unwind_plan_sp;
+}
+
 unwind_plan_sp =
 func_unwinders_sp->GetEHFrameUnwindPlan(process->GetTarget());
 if (!unwind_plan_sp)
Index: lldb/source/Plugins/Platform/Linux/PlatformLinux.h
===
--- lldb/source/Plugins/Platform/Linux/PlatformLinux.h
+++ lldb/source/Plugins/Platform/Linux/PlatformLinux.h
@@ -50,6 +50,9 @@
 
   void CalculateTrapHandlerSymbolNames() override;
 
+  lldb::UnwindPlanSP GetTrapHandlerUnwindPlan(llvm::Triple::ArchType machine,
+  ConstString name) override;
+
   MmapArgList GetMmapArgumentList(const ArchSpec &arch, lldb::addr_t addr,
   lldb::addr_t length, unsigned prot,
   unsigned flags, lldb::addr_t fd,
Index: lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
===
--- lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -14,9 +14,11 @@
 #include 
 #endif
 
+#include "Utility/ARM64_DWARF_Registers.h"
 #include "lldb/Core/Debugger.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Host/HostInfo.h"
+#include "lldb/Symbol/UnwindPlan.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Tar

[Lldb-commits] [PATCH] D112537: Set synthetic children

2021-10-26 Thread walter erquinigo via Phabricator via lldb-commits
wallace requested changes to this revision.
wallace added a comment.
This revision now requires changes to proceed.

I think you messed up when updating the diffs. I don't see the bitset diff 
anymore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112537

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


[Lldb-commits] [PATCH] D112180: [formatters] Add a libstdcpp formatter for set and unify tests across stdlibs

2021-10-26 Thread walter erquinigo via Phabricator via lldb-commits
wallace requested changes to this revision.
wallace added a comment.
This revision now requires changes to proceed.

I think you messed up when updating the diffs. I don't see the bitset diff 
anymore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112180

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


[Lldb-commits] [PATCH] D112180: [formatters] Add a libstdcpp formatter for set and unify tests across stdlibs

2021-10-26 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan updated this revision to Diff 382370.
danilashtefan added a comment.

Fixing


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112180

Files:
  lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
@@ -1,29 +1,28 @@
 #include 
 #include 
 
-template
-void fill(std::bitset &b) {
+template  void fill(std::bitset &b) {
   b.set();
   b[0] = b[1] = false;
   for (std::size_t i = 2; i < N; ++i) {
-for (std::size_t j = 2*i; j < N; j+=i)
+for (std::size_t j = 2 * i; j < N; j += i)
   b[j] = false;
   }
 }
 
-template
+template 
 void by_ref_and_ptr(std::bitset &ref, std::bitset *ptr) {
-// Check ref and ptr
-return;
+  // Check ref and ptr
+  return;
 }
 
 int main() {
   std::bitset<0> empty;
   std::bitset<13> small;
   fill(small);
-  std::bitset<200> large;
+  std::bitset<70> large;
   fill(large);
   by_ref_and_ptr(small, &small); // break here
-  by_ref_and_ptr(large, &large);
+  by_ref_and_ptr(large, &large); 
   return 0;
 }
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
@@ -1,5 +1,5 @@
 """
-Test lldb data formatter subsystem.
+Test lldb data formatter subsystem for bitset for libcxx and libstdcpp.
 """
 
 
@@ -9,14 +9,15 @@
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import lldbutil
 
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+USE_LIBCPP = "USE_LIBCPP"
 
-class TestDataFormatterLibcxxBitset(TestBase):
+class GenericBitsetDataFormatterTestCase(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
 def setUp(self):
 TestBase.setUp(self)
-
 primes = [1]*300
 primes[0] = primes[1] = 0
 for i in range(2, len(primes)):
@@ -33,21 +34,29 @@
 self.assertEqual(child.GetValueAsUnsigned(), self.primes[i],
 "variable: %s, index: %d"%(name, size))
 
-@add_test_categories(["libc++"])
-def test_value(self):
+def do_test_value(self, stdlib_type):
 """Test that std::bitset is displayed correctly"""
-self.build()
+self.build(dictionary={stdlib_type: "1"})
+
 lldbutil.run_to_source_breakpoint(self, '// break here',
 lldb.SBFileSpec("main.cpp", False))
 
 self.check("empty", 0)
 self.check("small", 13)
-self.check("large", 200)
+self.check("large", 70)
+
+@add_test_categories(["libstdcxx"])
+def test_value_libstdcpp(self):
+self.do_test_value(USE_LIBSTDCPP)
 
 @add_test_categories(["libc++"])
-def test_ptr_and_ref(self):
+def test_value_libcpp(self):
+self.do_test_value(USE_LIBCPP)
+
+def do_test_ptr_and_ref(self, stdlib_type):
 """Test that ref and ptr to std::bitset is displayed correctly"""
-self.build()
+self.build(dictionary={stdlib_type: "1"})
+
 (_, process, _, bkpt) = lldbutil.run_to_source_breakpoint(self,
 'Check ref and ptr',
 lldb.SBFileSpec("main.cpp", False))
@@ -57,5 +66,13 @@
 
 lldbutil.continue_to_breakpoint(process, bkpt)
 
-self.check("ref", 200)
-self.check("ptr", 200)
+self.check("ref", 70)
+self.check("ptr", 70)
+
+@add_test_categories(["libstdcxx"])
+def test_ptr_and_ref_libstdcpp(self):
+self.do_test_ptr_and_ref(USE_LIBSTDCPP)
+
+@add_test_categories(["libc++"])
+def test_ptr_and_ref_libcpp(self):
+self.do_test_ptr_and_ref

[Lldb-commits] [PATCH] D112439: normalize file path when searching the source map

2021-10-26 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Target/PathMappingList.cpp:33-37
   ConstString NormalizePath(ConstString path) {
 // If we use "path" to construct a FileSpec, it will normalize the path for
 // us. We then grab the string and turn it back into a ConstString.
 return ConstString(FileSpec(path.GetStringRef()).GetPath());
   }

Can this function take a `StringRef` and return a `std::string` instead? The 
amount of roundtrips between `StringRef`s, `ConstString`s and `std::string`s is 
getting a bit out of hand.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112439

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


[Lldb-commits] [PATCH] D112564: [lldb] Add support for custom char8_t types with different name

2021-10-26 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 created this revision.
ljmf00 added projects: LLDB, LLVM.
Herald added a subscriber: JDevlieghere.
ljmf00 requested review of this revision.
Herald added a subscriber: lldb-commits.

  Currently for UTF-16 and UTF-32 types that are recognized by the DWARF 
encoding
  tags without `char16_t` and `char32_t` names respectively are recognized, but
  other names different than `char8_t` are not. To support the same behaviour of
  the previous encodings, DWARF encoding tags should be taken to consideration
  before fallbacking into the type name.
  
  Signed-off-by: Luís Ferreira 

Cross-referencing https://reviews.llvm.org/D66447


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112564

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


Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5155,6 +5155,8 @@
 case clang::BuiltinType::UChar:
 case clang::BuiltinType::WChar_U:
   return lldb::eFormatChar;
+case clang::BuiltinType::Char8:
+  return lldb::eFormatUnicode8;
 case clang::BuiltinType::Char16:
   return lldb::eFormatUnicode16;
 case clang::BuiltinType::Char32:


Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -5155,6 +5155,8 @@
 case clang::BuiltinType::UChar:
 case clang::BuiltinType::WChar_U:
   return lldb::eFormatChar;
+case clang::BuiltinType::Char8:
+  return lldb::eFormatUnicode8;
 case clang::BuiltinType::Char16:
   return lldb::eFormatUnicode16;
 case clang::BuiltinType::Char32:
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D112357: [lldb] [Host] Move port predicate-related logic to gdb-remote

2021-10-26 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.
Herald added a subscriber: JDevlieghere.

Hi @mgorny, this broke green-dragon 
(https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/37098/consoleText). 
You should be able to reproduce by running `$ ninja check-lldb-unit`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112357

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


[Lldb-commits] [PATCH] D111899: LLDB tests modification for hardware breakpoints

2021-10-26 Thread Jim Ingham via Phabricator via lldb-commits
jingham accepted this revision.
jingham added a comment.

There's one comment typo, but you can fix that on submission.  Otherwise, LGTM.




Comment at: lldb/packages/Python/lldbsuite/test/lldbutil.py:654
+Test breakpoint or breakpoint location.
+Breakpoint resolved count is always checked. If not specified the 
assumption is that all location 
+should be resolved. 

location -> locations


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

https://reviews.llvm.org/D111899

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


[Lldb-commits] [lldb] 801cf36 - [lldb] [unittests] Fix TcpListen() call in RNBSocketTest

2021-10-26 Thread Michał Górny via lldb-commits

Author: Michał Górny
Date: 2021-10-26T21:08:03+02:00
New Revision: 801cf36a23bd17eefa7b8b344693b5691675128c

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

LOG: [lldb] [unittests] Fix TcpListen() call in RNBSocketTest

Added: 


Modified: 
lldb/unittests/debugserver/RNBSocketTest.cpp

Removed: 




diff  --git a/lldb/unittests/debugserver/RNBSocketTest.cpp 
b/lldb/unittests/debugserver/RNBSocketTest.cpp
index 8db4c9b8bb4d2..75f236b4d4180 100644
--- a/lldb/unittests/debugserver/RNBSocketTest.cpp
+++ b/lldb/unittests/debugserver/RNBSocketTest.cpp
@@ -101,10 +101,8 @@ void TestSocketConnect(const char *addr) {
 sprintf(addr_wrap, "%s:0", addr);
 
   Socket *server_socket;
-  Predicate port_predicate;
-  port_predicate.SetValue(0, eBroadcastNever);
   llvm::Expected> socket_or_err =
-  Socket::TcpListen(addr_wrap, false, &port_predicate);
+  Socket::TcpListen(addr_wrap, false);
   ASSERT_THAT_EXPECTED(socket_or_err, llvm::Succeeded());
   server_socket = socket_or_err->get();
 



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


[Lldb-commits] [PATCH] D112564: [lldb] Add support for custom char8_t types with different name

2021-10-26 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 added a comment.

I can reproduce this with LDC (D LLVM-based compiler), but I don't know a way 
to do it with clang. Probably I need to manually write a .ll file for this. Can 
someone guide me on adding tests for this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112564

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


[Lldb-commits] [PATCH] D112564: [lldb] Add support for custom char8_t types with different name

2021-10-26 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 added a comment.

I will also create an issue and cross-reference this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112564

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


[Lldb-commits] [PATCH] D112357: [lldb] [Host] Move port predicate-related logic to gdb-remote

2021-10-26 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

In D112357#3088305 , @mib wrote:

> Hi @mgorny, this broke green-dragon 
> (https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/37098/consoleText).
>  You should be able to reproduce by running `$ ninja check-lldb-unit`

I'm sorry about that. I don't think I can test it since AFAICS debugserver 
isn't built on non-Apple systems. However, I've pushed a fix and hopefully I 
haven't made a mistake.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112357

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


[Lldb-commits] [PATCH] D112357: [lldb] [Host] Move port predicate-related logic to gdb-remote

2021-10-26 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib added a comment.

In D112357#3088505 , @mgorny wrote:

> In D112357#3088305 , @mib wrote:
>
>> Hi @mgorny, this broke green-dragon 
>> (https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/37098/consoleText).
>>  You should be able to reproduce by running `$ ninja check-lldb-unit`
>
> I'm sorry about that. I don't think I can test it since AFAICS debugserver 
> isn't built on non-Apple systems. However, I've pushed a fix and hopefully I 
> haven't made a mistake.

Thanks, that fixed the bot 
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/37105


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112357

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


[Lldb-commits] [PATCH] D112180: [formatters] Add a libstdcpp formatter for set and unify tests across stdlibs

2021-10-26 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan updated this revision to Diff 382453.
danilashtefan added a comment.

With this changes I substitute the verbose long printed check with ValueCheck 
approach


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112180

Files:
  lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py
+++ /dev/null
@@ -1,61 +0,0 @@
-"""
-Test lldb data formatter subsystem.
-"""
-
-
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class TestDataFormatterLibcxxBitset(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-def setUp(self):
-TestBase.setUp(self)
-
-primes = [1]*300
-primes[0] = primes[1] = 0
-for i in range(2, len(primes)):
-for j in range(2*i, len(primes), i):
-primes[j] = 0
-self.primes = primes
-
-def check(self, name, size):
-var = self.frame().FindVariable(name)
-self.assertTrue(var.IsValid())
-self.assertEqual(var.GetNumChildren(), size)
-for i in range(size):
-child = var.GetChildAtIndex(i)
-self.assertEqual(child.GetValueAsUnsigned(), self.primes[i],
-"variable: %s, index: %d"%(name, size))
-
-@add_test_categories(["libc++"])
-def test_value(self):
-"""Test that std::bitset is displayed correctly"""
-self.build()
-lldbutil.run_to_source_breakpoint(self, '// break here',
-lldb.SBFileSpec("main.cpp", False))
-
-self.check("empty", 0)
-self.check("small", 13)
-self.check("large", 200)
-
-@add_test_categories(["libc++"])
-def test_ptr_and_ref(self):
-"""Test that ref and ptr to std::bitset is displayed correctly"""
-self.build()
-(_, process, _, bkpt) = lldbutil.run_to_source_breakpoint(self,
-'Check ref and ptr',
-lldb.SBFileSpec("main.cpp", False))
-
-self.check("ref", 13)
-self.check("ptr", 13)
-
-lldbutil.continue_to_breakpoint(process, bkpt)
-
-self.check("ref", 200)
-self.check("ptr", 200)
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
@@ -1,29 +1,28 @@
 #include 
 #include 
 
-template
-void fill(std::bitset &b) {
+template  void fill(std::bitset &b) {
   b.set();
   b[0] = b[1] = false;
   for (std::size_t i = 2; i < N; ++i) {
-for (std::size_t j = 2*i; j < N; j+=i)
+for (std::size_t j = 2 * i; j < N; j += i)
   b[j] = false;
   }
 }
 
-template
+template 
 void by_ref_and_ptr(std::bitset &ref, std::bitset *ptr) {
-// Check ref and ptr
-return;
+  // Check ref and ptr
+  return;
 }
 
 int main() {
   std::bitset<0> empty;
   std::bitset<13> small;
   fill(small);
-  std::bitset<200> large;
+  std::bitset<70> large;
   fill(large);
   by_ref_and_ptr(small, &small); // break here
-  by_ref_and_ptr(large, &large);
+  by_ref_and_ptr(large, &large); 
   return 0;
 }
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
@@ -0,0 +1,89 @@
+"""
+Test lldb data formatter subsystem for bitset for libcxx and libstdcpp.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from l

[Lldb-commits] [PATCH] D112180: [formatters] Add a libstdcpp formatter for bitset and unify tests across stdlibs

2021-10-26 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan updated this revision to Diff 382456.
danilashtefan added a comment.

Refactoring


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112180

Files:
  lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py
+++ /dev/null
@@ -1,61 +0,0 @@
-"""
-Test lldb data formatter subsystem.
-"""
-
-
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class TestDataFormatterLibcxxBitset(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-def setUp(self):
-TestBase.setUp(self)
-
-primes = [1]*300
-primes[0] = primes[1] = 0
-for i in range(2, len(primes)):
-for j in range(2*i, len(primes), i):
-primes[j] = 0
-self.primes = primes
-
-def check(self, name, size):
-var = self.frame().FindVariable(name)
-self.assertTrue(var.IsValid())
-self.assertEqual(var.GetNumChildren(), size)
-for i in range(size):
-child = var.GetChildAtIndex(i)
-self.assertEqual(child.GetValueAsUnsigned(), self.primes[i],
-"variable: %s, index: %d"%(name, size))
-
-@add_test_categories(["libc++"])
-def test_value(self):
-"""Test that std::bitset is displayed correctly"""
-self.build()
-lldbutil.run_to_source_breakpoint(self, '// break here',
-lldb.SBFileSpec("main.cpp", False))
-
-self.check("empty", 0)
-self.check("small", 13)
-self.check("large", 200)
-
-@add_test_categories(["libc++"])
-def test_ptr_and_ref(self):
-"""Test that ref and ptr to std::bitset is displayed correctly"""
-self.build()
-(_, process, _, bkpt) = lldbutil.run_to_source_breakpoint(self,
-'Check ref and ptr',
-lldb.SBFileSpec("main.cpp", False))
-
-self.check("ref", 13)
-self.check("ptr", 13)
-
-lldbutil.continue_to_breakpoint(process, bkpt)
-
-self.check("ref", 200)
-self.check("ptr", 200)
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
@@ -1,29 +1,28 @@
 #include 
 #include 
 
-template
-void fill(std::bitset &b) {
+template  void fill(std::bitset &b) {
   b.set();
   b[0] = b[1] = false;
   for (std::size_t i = 2; i < N; ++i) {
-for (std::size_t j = 2*i; j < N; j+=i)
+for (std::size_t j = 2 * i; j < N; j += i)
   b[j] = false;
   }
 }
 
-template
+template 
 void by_ref_and_ptr(std::bitset &ref, std::bitset *ptr) {
-// Check ref and ptr
-return;
+  // Check ref and ptr
+  return;
 }
 
 int main() {
   std::bitset<0> empty;
   std::bitset<13> small;
   fill(small);
-  std::bitset<200> large;
+  std::bitset<70> large;
   fill(large);
   by_ref_and_ptr(small, &small); // break here
-  by_ref_and_ptr(large, &large);
+  by_ref_and_ptr(large, &large); 
   return 0;
 }
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
@@ -0,0 +1,93 @@
+"""
+Test lldb data formatter subsystem for bitset for libcxx and libstdcpp.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+USE_LIBCPP

[Lldb-commits] [PATCH] D112537: [formatters] Add a libstdcpp formatter for set and unify tests across stdlibs

2021-10-26 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

just some minor things left




Comment at: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp:941-942
   new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
+  TypeSummaryImpl::Flags stl_set_summary_flags = stl_summary_flags;
+  stl_set_summary_flags.SetSkipPointers(false).SetDontShowValue(false);
+  cpp_category_sp->GetRegexTypeSummariesContainer()->Add(

to mimic the libcxx case that you can see in the line 710 of 
https://lldb.llvm.org/cpp_reference/CPlusPlusLanguage_8cpp_source.html, you can 
do stl_summary_flags.SetSkipPointers(false) in line 932 of this file. Then both 
standard libraries will be handled the same way. Make sure to execute the 
relevant tests for vector, map, set and list for libstdcpp.
This also means that you don't need the new variable stl_set_summary_flags



Comment at: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/Makefile:4
 
-CXXFLAGS_EXTRAS := -O0
+
 include Makefile.rules

remove this line



Comment at: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/set/TestDataFormatterGenericSet.py:45
 "[3] = 3",
 "[6] = 6"])
 

can you add additional assertions like the one you did in 
https://reviews.llvm.org/D112180 that uses ValueCheck?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112537

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


[Lldb-commits] [PATCH] D112537: [formatters] Add a libstdcpp formatter for set and unify tests across stdlibs

2021-10-26 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

Besides, given that you are using the same python implementation for map and 
set, better rename the class to StdSeOrMapSynthProvider and add a comment 
mentioning that it works both for set and maps because they have the same 
underlying structure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112537

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


[Lldb-commits] [PATCH] D112180: [formatters] Add a libstdcpp formatter for bitset and unify tests across stdlibs

2021-10-26 Thread Danil Stefaniuc via Phabricator via lldb-commits
danilashtefan updated this revision to Diff 382463.
danilashtefan added a comment.

Reactoring


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112180

Files:
  lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py
+++ /dev/null
@@ -1,61 +0,0 @@
-"""
-Test lldb data formatter subsystem.
-"""
-
-
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class TestDataFormatterLibcxxBitset(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-def setUp(self):
-TestBase.setUp(self)
-
-primes = [1]*300
-primes[0] = primes[1] = 0
-for i in range(2, len(primes)):
-for j in range(2*i, len(primes), i):
-primes[j] = 0
-self.primes = primes
-
-def check(self, name, size):
-var = self.frame().FindVariable(name)
-self.assertTrue(var.IsValid())
-self.assertEqual(var.GetNumChildren(), size)
-for i in range(size):
-child = var.GetChildAtIndex(i)
-self.assertEqual(child.GetValueAsUnsigned(), self.primes[i],
-"variable: %s, index: %d"%(name, size))
-
-@add_test_categories(["libc++"])
-def test_value(self):
-"""Test that std::bitset is displayed correctly"""
-self.build()
-lldbutil.run_to_source_breakpoint(self, '// break here',
-lldb.SBFileSpec("main.cpp", False))
-
-self.check("empty", 0)
-self.check("small", 13)
-self.check("large", 200)
-
-@add_test_categories(["libc++"])
-def test_ptr_and_ref(self):
-"""Test that ref and ptr to std::bitset is displayed correctly"""
-self.build()
-(_, process, _, bkpt) = lldbutil.run_to_source_breakpoint(self,
-'Check ref and ptr',
-lldb.SBFileSpec("main.cpp", False))
-
-self.check("ref", 13)
-self.check("ptr", 13)
-
-lldbutil.continue_to_breakpoint(process, bkpt)
-
-self.check("ref", 200)
-self.check("ptr", 200)
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
@@ -1,29 +1,28 @@
 #include 
 #include 
 
-template
-void fill(std::bitset &b) {
+template  void fill(std::bitset &b) {
   b.set();
   b[0] = b[1] = false;
   for (std::size_t i = 2; i < N; ++i) {
-for (std::size_t j = 2*i; j < N; j+=i)
+for (std::size_t j = 2 * i; j < N; j += i)
   b[j] = false;
   }
 }
 
-template
+template 
 void by_ref_and_ptr(std::bitset &ref, std::bitset *ptr) {
-// Check ref and ptr
-return;
+  // Check ref and ptr
+  return;
 }
 
 int main() {
   std::bitset<0> empty;
   std::bitset<13> small;
   fill(small);
-  std::bitset<200> large;
+  std::bitset<70> large;
   fill(large);
   by_ref_and_ptr(small, &small); // break here
-  by_ref_and_ptr(large, &large);
+  by_ref_and_ptr(large, &large); 
   return 0;
 }
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
@@ -0,0 +1,93 @@
+"""
+Test lldb data formatter subsystem for bitset for libcxx and libstdcpp.
+"""
+
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+USE_LIBSTDCPP = "USE_LIBSTDCPP"
+USE_LIBCPP 

[Lldb-commits] [PATCH] D112180: [formatters] Add a libstdcpp formatter for bitset and unify tests across stdlibs

2021-10-26 Thread walter erquinigo via Phabricator via lldb-commits
wallace accepted this revision.
wallace added a comment.

great! I'll land it for you


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112180

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


[Lldb-commits] [lldb] 566bfbb - [formatters] Add a libstdcpp formatter for bitset and unify tests across stdlibs

2021-10-26 Thread Walter Erquinigo via lldb-commits

Author: Danil Stefaniuc
Date: 2021-10-26T14:49:50-07:00
New Revision: 566bfbb740bb0ffef827ce983d7aa899236fcb88

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

LOG: [formatters] Add a libstdcpp formatter for bitset and unify tests across 
stdlibs

This diff adds a data formatter for libstdcpp's bitset. Besides, it unifies the 
tests for bitset for libcxx and libstdcpp for maintainability.

Reviewed By: wallace

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

Added: 
lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py

lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp

Modified: 
lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h

Removed: 
lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/Makefile

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py

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



diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt 
b/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
index 2a541a9e528cd..eb53649ab0ff9 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
+++ b/lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
@@ -3,9 +3,9 @@ add_lldb_library(lldbPluginCPlusPlusLanguage PLUGIN
   CPlusPlusLanguage.cpp
   CPlusPlusNameParser.cpp
   CxxStringTypes.cpp
+  GenericBitset.cpp
   LibCxx.cpp
   LibCxxAtomic.cpp
-  LibCxxBitset.cpp
   LibCxxInitializerList.cpp
   LibCxxList.cpp
   LibCxxMap.cpp

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 4ef35eefaf32f..240bbecfc2c53 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -895,6 +895,8 @@ static void 
LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   SyntheticChildren::Flags stl_synth_flags;
   stl_synth_flags.SetCascades(true).SetSkipPointers(false).SetSkipReferences(
   false);
+  SyntheticChildren::Flags stl_deref_flags = stl_synth_flags;
+  stl_deref_flags.SetFrontEndWantsDereference();
 
   cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
   RegularExpression("^std::vector<.+>(( )?&)?$"),
@@ -913,6 +915,10 @@ static void 
LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider")));
   stl_summary_flags.SetDontShowChildren(false);
   stl_summary_flags.SetSkipPointers(true);
+  cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
+  RegularExpression("^std::bitset<.+>(( )?&)?$"),
+  TypeSummaryImplSP(
+  new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
   cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
   RegularExpression("^std::vector<.+>(( )?&)?$"),
   TypeSummaryImplSP(
@@ -959,6 +965,12 @@ static void 
LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
   "std::tuple synthetic children", ConstString("^std::tuple<.+>(( )?&)?$"),
   stl_synth_flags, true);
 
+  AddCXXSynthetic(
+  cpp_category_sp,
+  lldb_private::formatters::LibStdcppBitsetSyntheticFrontEndCreator,
+  "std::bitset synthetic child", ConstString("^std::bitset<.+>(( )?&)?$"),
+  stl_deref_flags, true);
+
   AddCXXSummary(cpp_category_sp,
 
lldb_private::formatters::LibStdcppUniquePointerSummaryProvider,
 "libstdc++ std::unique_ptr summary provider",

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
similarity index 71%
rename from lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
rename to lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
index e5b868fc0fce0..fc8255983436c 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
@@ -1,4 +1,4 @@
-//===-- LibCxxBitset.cpp 
--===//
+//===-- GenericBitset.cpp 
//---===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for l

[Lldb-commits] [PATCH] D112180: [formatters] Add a libstdcpp formatter for bitset and unify tests across stdlibs

2021-10-26 Thread Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG566bfbb740bb: [formatters] Add a libstdcpp formatter for 
bitset and unify tests across stdlibs (authored by danilashtefan, committed by 
Walter Erquinigo ).

Changed prior to commit:
  https://reviews.llvm.org/D112180?vs=382463&id=382468#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112180

Files:
  lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxxBitset.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.h
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/bitset/TestDataFormatterLibcxxBitset.py
+++ /dev/null
@@ -1,61 +0,0 @@
-"""
-Test lldb data formatter subsystem.
-"""
-
-
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class TestDataFormatterLibcxxBitset(TestBase):
-
-mydir = TestBase.compute_mydir(__file__)
-
-def setUp(self):
-TestBase.setUp(self)
-
-primes = [1]*300
-primes[0] = primes[1] = 0
-for i in range(2, len(primes)):
-for j in range(2*i, len(primes), i):
-primes[j] = 0
-self.primes = primes
-
-def check(self, name, size):
-var = self.frame().FindVariable(name)
-self.assertTrue(var.IsValid())
-self.assertEqual(var.GetNumChildren(), size)
-for i in range(size):
-child = var.GetChildAtIndex(i)
-self.assertEqual(child.GetValueAsUnsigned(), self.primes[i],
-"variable: %s, index: %d"%(name, size))
-
-@add_test_categories(["libc++"])
-def test_value(self):
-"""Test that std::bitset is displayed correctly"""
-self.build()
-lldbutil.run_to_source_breakpoint(self, '// break here',
-lldb.SBFileSpec("main.cpp", False))
-
-self.check("empty", 0)
-self.check("small", 13)
-self.check("large", 200)
-
-@add_test_categories(["libc++"])
-def test_ptr_and_ref(self):
-"""Test that ref and ptr to std::bitset is displayed correctly"""
-self.build()
-(_, process, _, bkpt) = lldbutil.run_to_source_breakpoint(self,
-'Check ref and ptr',
-lldb.SBFileSpec("main.cpp", False))
-
-self.check("ref", 13)
-self.check("ptr", 13)
-
-lldbutil.continue_to_breakpoint(process, bkpt)
-
-self.check("ref", 200)
-self.check("ptr", 200)
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/main.cpp
@@ -1,27 +1,26 @@
 #include 
 #include 
 
-template
-void fill(std::bitset &b) {
+template  void fill(std::bitset &b) {
   b.set();
   b[0] = b[1] = false;
   for (std::size_t i = 2; i < N; ++i) {
-for (std::size_t j = 2*i; j < N; j+=i)
+for (std::size_t j = 2 * i; j < N; j += i)
   b[j] = false;
   }
 }
 
-template
+template 
 void by_ref_and_ptr(std::bitset &ref, std::bitset *ptr) {
-// Check ref and ptr
-return;
+  // Check ref and ptr
+  return;
 }
 
 int main() {
   std::bitset<0> empty;
   std::bitset<13> small;
   fill(small);
-  std::bitset<200> large;
+  std::bitset<70> large;
   fill(large);
   by_ref_and_ptr(small, &small); // break here
   by_ref_and_ptr(large, &large);
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-fo

[Lldb-commits] [PATCH] D112180: [formatters] Add a libstdcpp formatter for bitset and unify tests across stdlibs

2021-10-26 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

Pushed upstream as 566bfbb740bb0ffef827ce983d7aa899236fcb88 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112180

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


[Lldb-commits] [lldb] 2887d9f - Add new key/value pairs to the module statistics for "statistics dump".

2021-10-26 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2021-10-26T15:09:31-07:00
New Revision: 2887d9fd864c9302608ecd7ff58b28ad181ede9d

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

LOG: Add new key/value pairs to the module statistics for "statistics dump".

The new key/value pairs that are added to each module's stats are:
"debugInfoByteSize": The size in bytes of debug info for each module.
"debugInfoIndexTime": The time in seconds that it took to index the debug info.
"debugInfoParseTime": The time in seconds that debug info had to be parsed.

At the top level we add up all of the debug info size, parse time and index 
time with the following keys:
"totalDebugInfoByteSize": The size in bytes of all debug info in all modules.
"totalDebugInfoIndexTime": The time in seconds that it took to index all debug 
info if it was indexed for all modules.
"totalDebugInfoParseTime": The time in seconds that debug info was parsed for 
all modules.

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

Added: 


Modified: 
lldb/include/lldb/Core/Section.h
lldb/include/lldb/Symbol/SymbolFile.h
lldb/include/lldb/Target/Statistics.h
lldb/source/Core/Section.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
lldb/source/Symbol/SymbolFile.cpp
lldb/source/Target/Statistics.cpp
lldb/test/API/commands/statistics/basic/TestStats.py

Removed: 




diff  --git a/lldb/include/lldb/Core/Section.h 
b/lldb/include/lldb/Core/Section.h
index 3d4ab154e743f..8a9fea3743141 100644
--- a/lldb/include/lldb/Core/Section.h
+++ b/lldb/include/lldb/Core/Section.h
@@ -89,6 +89,12 @@ class SectionList {
 
   void Clear() { m_sections.clear(); }
 
+  /// Get the debug information size from all sections that contain debug
+  /// information. Symbol tables are not considered part of the debug
+  /// information for this call, just known sections that contain debug
+  /// information.
+  uint64_t GetDebugInfoSize() const;
+
 protected:
   collection m_sections;
 };
@@ -236,6 +242,13 @@ class Section : public 
std::enable_shared_from_this,
 
   void SetIsRelocated(bool b) { m_relocated = b; }
 
+  /// Returns true if this section contains debug information. Symbol tables
+  /// are not considered debug information since some symbols might contain
+  /// debug information (STABS, COFF) but not all symbols do, so to keep this
+  /// fast and simple only sections that contains only debug information should
+  /// return true.
+  bool ContainsOnlyDebugInfo() const;
+
 protected:
   ObjectFile *m_obj_file;   // The object file that data for this section 
should
 // be read from

diff  --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index ffdbdc6853f75..9ab63cac56dda 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -19,6 +19,7 @@
 #include "lldb/Symbol/Type.h"
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Symbol/TypeSystem.h"
+#include "lldb/Target/Statistics.h"
 #include "lldb/Utility/XcodeSDK.h"
 #include "lldb/lldb-private.h"
 #include "llvm/ADT/DenseSet.h"
@@ -299,6 +300,38 @@ class SymbolFile : public PluginInterface {
 
   virtual void Dump(Stream &s);
 
+  /// Metrics gathering functions
+
+  /// Return the size in bytes of all debug information in the symbol file.
+  ///
+  /// If the debug information is contained in sections of an ObjectFile, then
+  /// this call should add the size of all sections that contain debug
+  /// information. Symbols the symbol tables are not considered debug
+  /// information for this call to make it easy and quick for this number to be
+  /// calculated. If the symbol file is all debug information, the size of the
+  /// entire file should be returned. The default implementation of this
+  /// function will iterate over all sections in a module and add up their
+  /// debug info only section byte sizes.
+  virtual uint64_t GetDebugInfoSize();
+
+  /// Return the time taken to parse the debug information.
+  ///
+  /// \returns 0.0 if no information has been parsed or if there is
+  /// no computational cost to parsing the debug in

[Lldb-commits] [PATCH] D112501: Add new key/value pairs to the module statistics for "statistics dump".

2021-10-26 Thread Greg Clayton via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2887d9fd864c: Add new key/value pairs to the module 
statistics for "statistics dump". (authored by clayborg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112501

Files:
  lldb/include/lldb/Core/Section.h
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/include/lldb/Target/Statistics.h
  lldb/source/Core/Section.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  lldb/source/Symbol/SymbolFile.cpp
  lldb/source/Target/Statistics.cpp
  lldb/test/API/commands/statistics/basic/TestStats.py

Index: lldb/test/API/commands/statistics/basic/TestStats.py
===
--- lldb/test/API/commands/statistics/basic/TestStats.py
+++ lldb/test/API/commands/statistics/basic/TestStats.py
@@ -144,6 +144,9 @@
 "moduleIdentifiers": [...],
 }
   ],
+  "totalDebugInfoByteSize": 182522234,
+  "totalDebugInfoIndexTime": 2.33343,
+  "totalDebugInfoParseTime": 8.212140024071,
   "totalSymbolTableParseTime": 0.123,
   "totalSymbolTableIndexTime": 0.234,
 }
@@ -155,6 +158,9 @@
 'targets',
 'totalSymbolTableParseTime',
 'totalSymbolTableIndexTime',
+'totalDebugInfoByteSize',
+'totalDebugInfoIndexTime',
+'totalDebugInfoParseTime',
 ]
 self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
 stats = debug_stats['targets'][0]
@@ -198,6 +204,9 @@
 },
 }
 ],
+"totalDebugInfoByteSize": 182522234,
+"totalDebugInfoIndexTime": 2.33343,
+"totalDebugInfoParseTime": 8.212140024071,
 "totalSymbolTableParseTime": 0.123,
 "totalSymbolTableIndexTime": 0.234,
 }
@@ -212,6 +221,9 @@
 'targets',
 'totalSymbolTableParseTime',
 'totalSymbolTableIndexTime',
+'totalDebugInfoByteSize',
+'totalDebugInfoIndexTime',
+'totalDebugInfoParseTime',
 ]
 self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
 stats = debug_stats['targets'][0]
@@ -247,6 +259,9 @@
 'targets',
 'totalSymbolTableParseTime',
 'totalSymbolTableIndexTime',
+'totalDebugInfoParseTime',
+'totalDebugInfoIndexTime',
+'totalDebugInfoByteSize'
 ]
 self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
 stats = debug_stats['targets'][0]
@@ -256,6 +271,9 @@
 self.verify_keys(stats, '"stats"', keys_exist, None)
 exe_module = self.find_module_in_metrics(exe, debug_stats)
 module_keys = [
+'debugInfoByteSize',
+'debugInfoIndexTime',
+'debugInfoParseTime',
 'identifier',
 'path',
 'symbolTableIndexTime',
Index: lldb/source/Target/Statistics.cpp
===
--- lldb/source/Target/Statistics.cpp
+++ lldb/source/Target/Statistics.cpp
@@ -50,6 +50,9 @@
   module.try_emplace("identifier", identifier);
   module.try_emplace("symbolTableParseTime", symtab_parse_time);
   module.try_emplace("symbolTableIndexTime", symtab_index_time);
+  module.try_emplace("debugInfoParseTime", debug_parse_time);
+  module.try_emplace("debugInfoIndexTime", debug_index_time);
+  module.try_emplace("debugInfoByteSize", (int64_t)debug_info_size);
   return module;
 }
 
@@ -109,6 +112,9 @@
   json::Array json_modules;
   double symtab_parse_time = 0.0;
   double symtab_index_time = 0.0;
+  double debug_parse_time = 0.0;
+  double debug_index_time = 0.0;
+  uint64_t debug_info_size = 0;
   if (target) {
 json_targets.emplace_back(target->ReportStatistics());
   } else {
@@ -119,18 +125,31 @@
   std::lock_guard guard(
   Module::GetAllocationModuleCollectionMutex());
   const size_t num_modules = Module::GetNumberAllocatedModules();
-  ModuleSP module_sp;
   for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
 Module *module = Module::GetAllocatedModuleAtIndex(image_idx);
 ModuleSta

[Lldb-commits] [PATCH] D112564: [lldb] Add support for custom char8_t types with different name

2021-10-26 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 added a comment.

https://bugs.llvm.org/show_bug.cgi?id=52324


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112564

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


[Lldb-commits] [PATCH] D112586: [lldb] Remove forgotten FIXME on CPlusPlus formatters

2021-10-26 Thread Luís Ferreira via Phabricator via lldb-commits
ljmf00 created this revision.
ljmf00 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

  The patch [1] introduced this FIXME but ended up not being removed when fixed.
  
  [1]: 
https://github.com/llvm/llvm-project/commit/f68df12fb039d5177e34f4541fa242b891949db6
  
  Signed-off-by: Luís Ferreira 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112586

Files:
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp


Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1010,8 +1010,6 @@
   .SetShowMembersOneLiner(false)
   .SetHideItemNames(false);
 
-  // FIXME because of a bug in the FormattersContainer we need to add a summary
-  // for both X* and const X* ()
   AddCXXSummary(
   cpp_category_sp, lldb_private::formatters::Char8StringSummaryProvider,
   "char8_t * summary provider", ConstString("char8_t *"), string_flags);


Index: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1010,8 +1010,6 @@
   .SetShowMembersOneLiner(false)
   .SetHideItemNames(false);
 
-  // FIXME because of a bug in the FormattersContainer we need to add a summary
-  // for both X* and const X* ()
   AddCXXSummary(
   cpp_category_sp, lldb_private::formatters::Char8StringSummaryProvider,
   "char8_t * summary provider", ConstString("char8_t *"), string_flags);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D112587: Add breakpoint resolving stats to each target.

2021-10-26 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg added reviewers: JDevlieghere, wallace, aadsm, labath, jingham.
clayborg requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This patch adds breakpoints to each target's statistics so we can track how 
long it takes to resolve each breakpoint. It also includes the structured data 
for each breakpoint so the exact breakpoint details are logged to allow for 
reproduction of slow resolving breakpoints. Each target gets a new 
"breakpoints" array that contains breakpoint details. Each breakpoint has 
"details" which is the JSON representation of a serialized breakpoint resolver 
and filter, "id" which is the breakpoint ID, and "resolveTime" which is the 
time in seconds it took to resolve the breakpoint. A snippet of the new data is 
shown here:

  "targets": [
{
  "breakpoints": [
{
  "details": {...},
  "id": 1,
  "resolveTime": 0.000392915999
},
{
  "details": {...},
  "id": 2,
  "resolveTime": 0.000226791999
}
  ],
  "totalBreakpointResolveTime": 0.000619707996
}
  ]

This provides full details on exactly how breakpoints were set and how long it 
took to resolve them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112587

Files:
  lldb/include/lldb/Breakpoint/Breakpoint.h
  lldb/source/Breakpoint/Breakpoint.cpp
  lldb/source/Target/Statistics.cpp
  lldb/test/API/commands/statistics/basic/TestStats.py

Index: lldb/test/API/commands/statistics/basic/TestStats.py
===
--- lldb/test/API/commands/statistics/basic/TestStats.py
+++ lldb/test/API/commands/statistics/basic/TestStats.py
@@ -283,3 +283,82 @@
 ]
 self.assertNotEqual(exe_module, None)
 self.verify_keys(exe_module, 'module dict for "%s"' % (exe), module_keys)
+
+def test_breakpoints(self):
+"""Test "statistics dump"
+
+Output expected to be something like:
+
+{
+  "modules" : [...],
+  "targets" : [
+{
+"firstStopTime": 0.3416449280001,
+"launchOrAttachTime": 0.3196960540001,
+"moduleIdentifiers": [...],
+"targetCreateTime": 0.00408630398
+"expressionEvaluation": {
+"failures": 0,
+"successes": 0
+},
+"frameVariable": {
+"failures": 0,
+"successes": 0
+},
+"breakpoints": [
+{
+"details": {...},
+"id": 1,
+"resolveTime": 2.65438675
+},
+{
+"details": {...},
+"id": 2,
+"resolveTime": 4.363258166997
+}
+]
+}
+],
+"totalDebugInfoByteSize": 182522234,
+"totalDebugInfoIndexTime": 2.33343,
+"totalDebugInfoParseTime": 8.212140024071,
+"totalSymbolTableParseTime": 0.123,
+"totalSymbolTableIndexTime": 0.234,
+"totalBreakpointResolveTime": 7.017644917001
+}
+
+"""
+target = self.createTestTarget()
+self.runCmd("b main.cpp:7")
+self.runCmd("b a_function")
+debug_stats = self.get_stats()
+debug_stat_keys = [
+'modules', 
+'targets',
+'totalSymbolTableParseTime',
+'totalSymbolTableIndexTime',
+'totalDebugInfoParseTime',
+'totalDebugInfoIndexTime',
+'totalDebugInfoByteSize',
+]
+self.verify_keys(debug_stats, '"debug_stats"', debug_stat_keys, None)
+target_stats = debug_stats['targets'][0]
+keys_exist = [
+'breakpoints',
+'expressionEvaluation',
+'frameVariable',
+'targetCreateTime',
+'moduleIdentifiers',
+'totalBreakpointResolveTime',
+]
+self.verify_keys(target_stats, '"stats"', keys_exist, None)
+self.assertGreater(target_stats['totalBreakpointResolveTime'], 0.0)
+breakpoints = target_stats['breakpoints']
+bp_keys_exist = [
+'details',
+'id',
+'resolveTime'
+]
+for breakpoint in breakpoints:
+self.verify_keys(breakpoint, 'target_stats["breakpoints"]', 
+ bp_keys_exist, None)
Index: lldb/source/Target/Statistics.cpp
===
--- lldb/source/Target/Statistics.cpp

[Lldb-commits] [PATCH] D112439: normalize file path when searching the source map

2021-10-26 Thread Xu Jun via Phabricator via lldb-commits
xujuntwt95329 added inline comments.



Comment at: lldb/source/Target/PathMappingList.cpp:33-37
   ConstString NormalizePath(ConstString path) {
 // If we use "path" to construct a FileSpec, it will normalize the path for
 // us. We then grab the string and turn it back into a ConstString.
 return ConstString(FileSpec(path.GetStringRef()).GetPath());
   }

JDevlieghere wrote:
> Can this function take a `StringRef` and return a `std::string` instead? The 
> amount of roundtrips between `StringRef`s, `ConstString`s and `std::string`s 
> is getting a bit out of hand.
I agree with you. 
However, if we change the signature of this function, then we need to do all 
these conversion from the caller side, seems things are not going better.

For example

```
void PathMappingList::Append(ConstString path,
 ConstString replacement, bool notify) {
  ++m_mod_id;
  m_pairs.emplace_back(pair(NormalizePath(path), NormalizePath(replacement)));
  if (notify && m_callback)
m_callback(*this, m_callback_baton);
}
```

We need to convert `path` to StringRef, or we can change the type of parameter 
`path`, but this will require more modification from the caller of `Append`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112439

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


[Lldb-commits] [PATCH] D112587: Add breakpoint resolving stats to each target.

2021-10-26 Thread walter erquinigo via Phabricator via lldb-commits
wallace requested changes to this revision.
wallace added inline comments.
This revision now requires changes to proceed.



Comment at: lldb/source/Breakpoint/Breakpoint.cpp:1120
+else
+  llvm::consumeError(expected_value.takeError());
+  }

err, i'm not a fan of this. Why don't you just make this return an expected and 
make the main command fail if the data couldn't be gathered? That will be 
better than concealing some possible parsing issues.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112587

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


[Lldb-commits] [lldb] 49481b5 - Remove ConstString from Language, LanguageRuntime, SystemRuntime and SymbolFile plugin names

2021-10-26 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2021-10-27T08:25:44+02:00
New Revision: 49481b538065a0ba5ba1d7cc901eeceb8bf344c0

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

LOG: Remove ConstString from Language, LanguageRuntime, SystemRuntime and 
SymbolFile plugin names

Added: 


Modified: 
lldb/include/lldb/Core/PluginManager.h
lldb/source/Core/PluginManager.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.h
lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.cpp
lldb/source/Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h

lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp

lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h

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

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

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

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

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp

lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.cpp
lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h
lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp

Removed: 




diff  --git a/lldb/include/lldb/Core/PluginManager.h 
b/lldb/include/lldb/Core/PluginManager.h
index aa51069cf4539..e027968c1b4d4 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -134,7 +134,7 @@ class PluginManager {
   GetOperatingSystemCreateCallbackForPluginName(llvm::StringRef name);
 
   // Language
-  static bool RegisterPlugin(ConstString name, const char *description,
+  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  LanguageCreateInstance create_callback);
 
   static bool UnregisterPlugin(LanguageCreateInstance create_callback);
@@ -143,7 +143,7 @@ class PluginManager {
 
   // LanguageRuntime
   static bool RegisterPlugin(
-  ConstString name, const char *description,
+  llvm::StringRef name, llvm::StringRef description,
   LanguageRuntimeCreateInstance create_callback,
   LanguageRuntimeGetCommandObject command_callback = nullptr,
   LanguageRuntimeGetExceptionPrecondition precondition_callback = nullptr);
@@ -160,7 +160,7 @@ class PluginManager {
   GetLanguageRuntimeGetExceptionPreconditionAtIndex(uint32_t idx);
 
   // SystemRuntime
-  static bool RegisterPlugin(ConstString name, const char *description,
+  static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  SystemRuntimeCreateInstance create_callback);
 
   static bool UnregisterPlugin(SystemRuntimeCreateInstance create_callback);
@@ -314,7 +314,7 @@ class PluginManager {
 
   // SymbolFile
   static bool
-  RegisterPlugin(ConstString name, const char *description,
+  RegisterPlugin(llvm::StringRef name, llvm::StringRef description,
  SymbolFileCreateInstance create_callback,
  DebuggerInitializeCallback debugger_init_callback = nullptr);
 

diff  --git a/lldb/source/Core/PluginManager.cpp 
b/lldb/source/Core/PluginManager.cpp
index fdf2aa7da4b32..db603c1160902 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -514,10 +514,11 @@ static LanguageInstances &GetLanguageInstances() {
   return g_instances;
 }
 
-bool PluginManager::RegisterPlugin(ConstString name, const char *description,
+bool PluginManager::RegisterPlugin(llvm:

[Lldb-commits] [PATCH] D112564: [lldb] Add support for custom char8_t types with different name

2021-10-26 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

What exactly do you need the test to do? Is printing a global variable 
(`char8_t_ish foo[] = "my string"`) sufficient?
If so, you can take a look at the tests in `test/Shell/SymbolFile/DWARF` for 
inspiration. There are .s and .ll tests there.
The pattern would roughly be:

  # RUN: llvm-mc (or llc) -o %t %s
  # RUN: %lldb %t -o "target variable foo" | FileCheck %s
  
  # CHECK: (char8_t_ish[]) foo = "my string"
  
  your code here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112564

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