Re: [Lldb-commits] [lldb] 4b074b4 - [lldb] Fix UB in half2float and add some more tests.

2021-05-20 Thread Raphael “Teemperor” Isemann via lldb-commits
I think what you're looking for is llvm::bit_cast (in ADT/bit.h) :) But that 
code was written before that, so that's why it's still using unions

> On 19 May 2021, at 23:27, Shafik Yaghmour  wrote:
> 
> *sigh*I wish we had std::bit_cast instead of using union based type punning, 
> we do have __builtin_bit_cast but it is different enough that replacing it 
> later on w/ std::bit_cast wouldn’t just be search/replace.
> 
>> On May 19, 2021, at 12:37 PM, Raphael Isemann via lldb-commits 
>>  wrote:
>> 
>> 
>> Author: Raphael Isemann
>> Date: 2021-05-19T21:37:10+02:00
>> New Revision: 4b074b49be206306330076b9fa40632ef1960823
>> 
>> URL: 
>> https://github.com/llvm/llvm-project/commit/4b074b49be206306330076b9fa40632ef1960823
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/4b074b49be206306330076b9fa40632ef1960823.diff
>> 
>> LOG: [lldb] Fix UB in half2float and add some more tests.
>> 
>> The added DumpDataExtractorTest uncovered that this is lshifting a negative
>> integer which upsets ubsan and breaks the sanitizer bot. This patch just
>> changes the variable we shift to be unsigned and adds a bunch of tests to 
>> make
>> sure this function does what it promises.
>> 
>> Added: 
>> 
>> 
>> Modified: 
>>   lldb/source/Core/DumpDataExtractor.cpp
>>   lldb/unittests/Core/DumpDataExtractorTest.cpp
>> 
>> Removed: 
>> 
>> 
>> 
>> 
>> diff  --git a/lldb/source/Core/DumpDataExtractor.cpp 
>> b/lldb/source/Core/DumpDataExtractor.cpp
>> index ec44e3481c1e5..34c9353c9feaa 100644
>> --- a/lldb/source/Core/DumpDataExtractor.cpp
>> +++ b/lldb/source/Core/DumpDataExtractor.cpp
>> @@ -52,7 +52,9 @@ static float half2float(uint16_t half) {
>>float f;
>>uint32_t u;
>>  } u;
>> -  int32_t v = (int16_t)half;
>> +  // Sign extend to 4 byte.
>> +  int32_t sign_extended = static_cast(half);
>> +  uint32_t v = static_cast(sign_extended);
>> 
>>  if (0 == (v & 0x7c00)) {
>>u.u = v & 0x80007FFFU;
>> 
>> diff  --git a/lldb/unittests/Core/DumpDataExtractorTest.cpp 
>> b/lldb/unittests/Core/DumpDataExtractorTest.cpp
>> index c4ec5f2e9a35b..05cd13add1e99 100644
>> --- a/lldb/unittests/Core/DumpDataExtractorTest.cpp
>> +++ b/lldb/unittests/Core/DumpDataExtractorTest.cpp
>> @@ -174,8 +174,30 @@ TEST(DumpDataExtractorTest, Formats) {
>>   "{0x 0x}");
>> 
>>  // See half2float for format details.
>> +  // Test zeroes.
>> +  TestDump(std::vector{0x, 0x8000},
>> +   lldb::Format::eFormatVectorOfFloat16, "{0 -0}");
>> +  // Some subnormal numbers.
>> +  TestDump(std::vector{0x0001, 0x8001},
>> +   lldb::Format::eFormatVectorOfFloat16, "{5.96046e-08 
>> -5.96046e-08}");
>> +  // A full mantisse and empty expontent.
>> +  TestDump(std::vector{0x83ff, 0x03ff},
>> +   lldb::Format::eFormatVectorOfFloat16, "{-6.09756e-05 
>> 6.09756e-05}");
>> +  // Some normal numbers.
>> +  TestDump(std::vector{0b011001001000},
>> +   lldb::Format::eFormatVectorOfFloat16, "{3.14062}");
>>  TestDump(std::vector{0xabcd, 0x1234},
>>   lldb::Format::eFormatVectorOfFloat16, "{-0.0609436 0.000757217}");
>> +  // Largest and smallest normal number.
>> +  TestDump(std::vector{0x0400, 0x7bff},
>> +   lldb::Format::eFormatVectorOfFloat16, "{6.10352e-05 65504}");
>> +  // quiet/signaling NaNs.
>> +  TestDump(std::vector{0x, 0xffc0, 0x7fff, 0x7fc0},
>> +   lldb::Format::eFormatVectorOfFloat16, "{nan nan nan nan}");
>> +  // +/-Inf.
>> +  TestDump(std::vector{0xfc00, 0x7c00},
>> +   lldb::Format::eFormatVectorOfFloat16, "{-inf inf}");
>> +
>>  TestDump(std::vector{std::numeric_limits::min(),
>>  std::numeric_limits::max()},
>>   lldb::Format::eFormatVectorOfFloat32, "{1.17549e-38 3.40282e+38}");
>> 
>> 
>> 
>> ___
>> lldb-commits mailing list
>> lldb-commits@lists.llvm.org
>> https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
> 

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


[Lldb-commits] [PATCH] D102833: [debugserver]Add platform cache support to improve performance.Under BigSur 11.3 this function causes a performance loss of 0.68s per execution.

2021-05-20 Thread kuperxu via Phabricator via lldb-commits
kuperxu created this revision.
kuperxu requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102833

Files:
  lldb/tools/debugserver/source/MacOSX/MachProcess.h
  lldb/tools/debugserver/source/MacOSX/MachProcess.mm


Index: lldb/tools/debugserver/source/MacOSX/MachProcess.mm
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -701,7 +701,7 @@
   // DYLD_FORCE_PLATFORM=6. In that case, force the platform to
   // macCatalyst and use the macCatalyst version of the host OS
   // instead of the macOS deployment target.
-  if (is_executable && GetProcessPlatformViaDYLDSPI() == PLATFORM_MACCATALYST) 
{
+  if (is_executable && GetPlatform() == PLATFORM_MACCATALYST) {
 info.platform = PLATFORM_MACCATALYST;
 std::string catalyst_version = GetMacCatalystVersionString();
 const char *major = catalyst_version.c_str();
@@ -1094,6 +1094,12 @@
   bool privateCache;
 };
 
+uint32_t MachProcess::GetPlatform() {
+  if (m_platform == 0)
+m_platform = MachProcess::GetProcessPlatformViaDYLDSPI();
+  return m_platform;
+}
+
 uint32_t MachProcess::GetProcessPlatformViaDYLDSPI() {
   kern_return_t kern_ret;
   uint32_t platform = 0;
@@ -1140,7 +1146,7 @@
   int pointer_size = GetInferiorAddrSize(pid);
   std::vector image_infos;
   GetAllLoadedBinariesViaDYLDSPI(image_infos);
-  uint32_t platform = GetProcessPlatformViaDYLDSPI();
+  uint32_t platform = GetPlatform();
   const size_t image_count = image_infos.size();
   for (size_t i = 0; i < image_count; i++) {
 GetMachOInformationFromMemory(platform, image_infos[i].load_address,
@@ -1160,7 +1166,7 @@
 
   std::vector all_image_infos;
   GetAllLoadedBinariesViaDYLDSPI(all_image_infos);
-  uint32_t platform = GetProcessPlatformViaDYLDSPI();
+  uint32_t platform = GetPlatform();
 
   std::vector image_infos;
   const size_t macho_addresses_count = macho_addresses.size();
Index: lldb/tools/debugserver/source/MacOSX/MachProcess.h
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.h
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.h
@@ -252,6 +252,7 @@
  struct mach_o_information &inf);
   JSONGenerator::ObjectSP FormatDynamicLibrariesIntoJSON(
   const std::vector &image_infos);
+  uint32_t GetPlatform();
   /// Get the runtime platform from DYLD via SPI.
   uint32_t GetProcessPlatformViaDYLDSPI();
   /// Use the dyld SPI present in macOS 10.12, iOS 10, tvOS 10,
@@ -378,6 +379,7 @@
 
   pid_t m_pid;   // Process ID of child process
   cpu_type_t m_cpu_type; // The CPU type of this process
+  uint32_t m_platform;   // The platform of this process
   int m_child_stdin;
   int m_child_stdout;
   int m_child_stderr;


Index: lldb/tools/debugserver/source/MacOSX/MachProcess.mm
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -701,7 +701,7 @@
   // DYLD_FORCE_PLATFORM=6. In that case, force the platform to
   // macCatalyst and use the macCatalyst version of the host OS
   // instead of the macOS deployment target.
-  if (is_executable && GetProcessPlatformViaDYLDSPI() == PLATFORM_MACCATALYST) {
+  if (is_executable && GetPlatform() == PLATFORM_MACCATALYST) {
 info.platform = PLATFORM_MACCATALYST;
 std::string catalyst_version = GetMacCatalystVersionString();
 const char *major = catalyst_version.c_str();
@@ -1094,6 +1094,12 @@
   bool privateCache;
 };
 
+uint32_t MachProcess::GetPlatform() {
+  if (m_platform == 0)
+m_platform = MachProcess::GetProcessPlatformViaDYLDSPI();
+  return m_platform;
+}
+
 uint32_t MachProcess::GetProcessPlatformViaDYLDSPI() {
   kern_return_t kern_ret;
   uint32_t platform = 0;
@@ -1140,7 +1146,7 @@
   int pointer_size = GetInferiorAddrSize(pid);
   std::vector image_infos;
   GetAllLoadedBinariesViaDYLDSPI(image_infos);
-  uint32_t platform = GetProcessPlatformViaDYLDSPI();
+  uint32_t platform = GetPlatform();
   const size_t image_count = image_infos.size();
   for (size_t i = 0; i < image_count; i++) {
 GetMachOInformationFromMemory(platform, image_infos[i].load_address,
@@ -1160,7 +1166,7 @@
 
   std::vector all_image_infos;
   GetAllLoadedBinariesViaDYLDSPI(all_image_infos);
-  uint32_t platform = GetProcessPlatformViaDYLDSPI();
+  uint32_t platform = GetPlatform();
 
   std::vector image_infos;
   const size_t macho_addresses_count = macho_addresses.size();
Index: lldb/tools/debugserver/source/MacOSX/MachProcess.h
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.h
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.h
@@ -252,6 +252,7 @@
 

[Lldb-commits] [PATCH] D102833: [debugserver]Add platform cache support to improve performance.Under BigSur 11.3 this function causes a performance loss of 0.68s per execution.

2021-05-20 Thread kuperxu via Phabricator via lldb-commits
kuperxu updated this revision to Diff 346671.
kuperxu added a comment.

[debugserver]Recalculate the platform cache each time the port is cleared.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102833

Files:
  lldb/tools/debugserver/source/MacOSX/MachProcess.h
  lldb/tools/debugserver/source/MacOSX/MachProcess.mm


Index: lldb/tools/debugserver/source/MacOSX/MachProcess.mm
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -701,7 +701,7 @@
   // DYLD_FORCE_PLATFORM=6. In that case, force the platform to
   // macCatalyst and use the macCatalyst version of the host OS
   // instead of the macOS deployment target.
-  if (is_executable && GetProcessPlatformViaDYLDSPI() == PLATFORM_MACCATALYST) 
{
+  if (is_executable && GetPlatform() == PLATFORM_MACCATALYST) {
 info.platform = PLATFORM_MACCATALYST;
 std::string catalyst_version = GetMacCatalystVersionString();
 const char *major = catalyst_version.c_str();
@@ -1094,6 +1094,12 @@
   bool privateCache;
 };
 
+uint32_t MachProcess::GetPlatform() {
+  if (m_platform == 0)
+m_platform = MachProcess::GetProcessPlatformViaDYLDSPI();
+  return m_platform;
+}
+
 uint32_t MachProcess::GetProcessPlatformViaDYLDSPI() {
   kern_return_t kern_ret;
   uint32_t platform = 0;
@@ -1140,7 +1146,7 @@
   int pointer_size = GetInferiorAddrSize(pid);
   std::vector image_infos;
   GetAllLoadedBinariesViaDYLDSPI(image_infos);
-  uint32_t platform = GetProcessPlatformViaDYLDSPI();
+  uint32_t platform = GetPlatform();
   const size_t image_count = image_infos.size();
   for (size_t i = 0; i < image_count; i++) {
 GetMachOInformationFromMemory(platform, image_infos[i].load_address,
@@ -1160,7 +1166,7 @@
 
   std::vector all_image_infos;
   GetAllLoadedBinariesViaDYLDSPI(all_image_infos);
-  uint32_t platform = GetProcessPlatformViaDYLDSPI();
+  uint32_t platform = GetPlatform();
 
   std::vector image_infos;
   const size_t macho_addresses_count = macho_addresses.size();
@@ -1324,6 +1330,7 @@
   // Clear any cached thread list while the pid and task are still valid
 
   m_task.Clear();
+  m_platform = 0;
   // Now clear out all member variables
   m_pid = INVALID_NUB_PROCESS;
   if (!detaching)
@@ -1615,6 +1622,7 @@
 
   // NULL our task out as we have already restored all exception ports
   m_task.Clear();
+  m_platform = 0;
 
   // Clear out any notion of the process we once were
   const bool detaching = true;
Index: lldb/tools/debugserver/source/MacOSX/MachProcess.h
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.h
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.h
@@ -252,6 +252,7 @@
  struct mach_o_information &inf);
   JSONGenerator::ObjectSP FormatDynamicLibrariesIntoJSON(
   const std::vector &image_infos);
+  uint32_t GetPlatform();
   /// Get the runtime platform from DYLD via SPI.
   uint32_t GetProcessPlatformViaDYLDSPI();
   /// Use the dyld SPI present in macOS 10.12, iOS 10, tvOS 10,
@@ -378,6 +379,7 @@
 
   pid_t m_pid;   // Process ID of child process
   cpu_type_t m_cpu_type; // The CPU type of this process
+  uint32_t m_platform;   // The platform of this process
   int m_child_stdin;
   int m_child_stdout;
   int m_child_stderr;


Index: lldb/tools/debugserver/source/MacOSX/MachProcess.mm
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -701,7 +701,7 @@
   // DYLD_FORCE_PLATFORM=6. In that case, force the platform to
   // macCatalyst and use the macCatalyst version of the host OS
   // instead of the macOS deployment target.
-  if (is_executable && GetProcessPlatformViaDYLDSPI() == PLATFORM_MACCATALYST) {
+  if (is_executable && GetPlatform() == PLATFORM_MACCATALYST) {
 info.platform = PLATFORM_MACCATALYST;
 std::string catalyst_version = GetMacCatalystVersionString();
 const char *major = catalyst_version.c_str();
@@ -1094,6 +1094,12 @@
   bool privateCache;
 };
 
+uint32_t MachProcess::GetPlatform() {
+  if (m_platform == 0)
+m_platform = MachProcess::GetProcessPlatformViaDYLDSPI();
+  return m_platform;
+}
+
 uint32_t MachProcess::GetProcessPlatformViaDYLDSPI() {
   kern_return_t kern_ret;
   uint32_t platform = 0;
@@ -1140,7 +1146,7 @@
   int pointer_size = GetInferiorAddrSize(pid);
   std::vector image_infos;
   GetAllLoadedBinariesViaDYLDSPI(image_infos);
-  uint32_t platform = GetProcessPlatformViaDYLDSPI();
+  uint32_t platform = GetPlatform();
   const size_t image_count = image_infos.size();
   for (size_t i = 0; i < image_count; i++) {
 GetMachOInformationFromMemory(platform, image_infos[i].load_address,
@@ -1160,7 +1166,7 @@
 
   std::vector 

[Lldb-commits] [PATCH] D102833: [debugserver]Add platform cache support to improve performance.Under BigSur 11.3 this function causes a performance loss of 0.68s per execution.

2021-05-20 Thread kuperxu via Phabricator via lldb-commits
kuperxu added a reviewer: aprantl.
kuperxu added a comment.

The main reason for the problem is that dyld has modified the 
_dyld_process_info_create function implementation, which has increased the 
function's time consumption significantly and caused a huge delay in attaching 
the program.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102833

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


[Lldb-commits] [PATCH] D102833: [debugserver]Add platform cache support to improve performance.Under BigSur 11.3 this function causes a performance loss of 0.68s per execution.

2021-05-20 Thread kuperxu via Phabricator via lldb-commits
kuperxu added a comment.

Currently the main time consuming performance is when loading the executable. 
In the MachProcess::GetMachOInformationFromMemory function if the executable 
has 100 load_command, then the function _dyld_process_info_create will be 
executed 100 times


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102833

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


[Lldb-commits] [lldb] 4878052 - [lldb][NFC] Add more Float16 unit tests

2021-05-20 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-05-20T17:07:23+02:00
New Revision: 48780527dd6820698f3537f5ebf76499030ee349

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

LOG: [lldb][NFC] Add more Float16 unit tests

Added: 


Modified: 
lldb/unittests/Core/DumpDataExtractorTest.cpp

Removed: 




diff  --git a/lldb/unittests/Core/DumpDataExtractorTest.cpp 
b/lldb/unittests/Core/DumpDataExtractorTest.cpp
index c4ec5f2e9a35..b678e62d8834 100644
--- a/lldb/unittests/Core/DumpDataExtractorTest.cpp
+++ b/lldb/unittests/Core/DumpDataExtractorTest.cpp
@@ -174,6 +174,21 @@ TEST(DumpDataExtractorTest, Formats) {
"{0x 0x}");
 
   // See half2float for format details.
+  // Test zeroes.
+  TestDump(std::vector{0x, 0x8000},
+   lldb::Format::eFormatVectorOfFloat16, "{0 -0}");
+  // Some subnormal numbers.
+  TestDump(std::vector{0x0001, 0x8001},
+   lldb::Format::eFormatVectorOfFloat16, "{5.96046e-08 -5.96046e-08}");
+  // A full mantisse and empty expontent.
+  TestDump(std::vector{0x83ff, 0x03ff},
+   lldb::Format::eFormatVectorOfFloat16, "{-6.09756e-05 6.09756e-05}");
+  // Some normal numbers.
+  TestDump(std::vector{0b011001001000},
+   lldb::Format::eFormatVectorOfFloat16, "{3.14062}");
+  // Largest and smallest normal number.
+  TestDump(std::vector{0x0400, 0x7bff},
+   lldb::Format::eFormatVectorOfFloat16, "{6.10352e-05 65504}");
   TestDump(std::vector{0xabcd, 0x1234},
lldb::Format::eFormatVectorOfFloat16, "{-0.0609436 0.000757217}");
   TestDump(std::vector{std::numeric_limits::min(),



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


[Lldb-commits] [lldb] 8ebaa19 - [lldb] Adjust DumpDataExtractorTest.Formats for Windows

2021-05-20 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-05-20T18:00:02+02:00
New Revision: 8ebaa195015dfd56f8413c43aa8f6d78ea7e6b30

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

LOG: [lldb] Adjust DumpDataExtractorTest.Formats for Windows

Not sure if that's the ostringstream or our conversion code, but this is
returning the wrong results on Windows.

Added: 


Modified: 
lldb/unittests/Core/DumpDataExtractorTest.cpp

Removed: 




diff  --git a/lldb/unittests/Core/DumpDataExtractorTest.cpp 
b/lldb/unittests/Core/DumpDataExtractorTest.cpp
index b678e62d8834..cfd24ff41491 100644
--- a/lldb/unittests/Core/DumpDataExtractorTest.cpp
+++ b/lldb/unittests/Core/DumpDataExtractorTest.cpp
@@ -185,7 +185,13 @@ TEST(DumpDataExtractorTest, Formats) {
lldb::Format::eFormatVectorOfFloat16, "{-6.09756e-05 6.09756e-05}");
   // Some normal numbers.
   TestDump(std::vector{0b011001001000},
-   lldb::Format::eFormatVectorOfFloat16, "{3.14062}");
+   lldb::Format::eFormatVectorOfFloat16,
+#ifdef _WIN32
+   // FIXME: This should print the same on all platforms.
+   "{3.14063}");
+#else
+   "{3.14062}");
+#endif
   // Largest and smallest normal number.
   TestDump(std::vector{0x0400, 0x7bff},
lldb::Format::eFormatVectorOfFloat16, "{6.10352e-05 65504}");



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


[Lldb-commits] [PATCH] D102851: [lldb] Improve invalid DWARF DW_AT_ranges error reporting

2021-05-20 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil created this revision.
jankratochvil added a reviewer: dblaikie.
jankratochvil added a project: LLDB.
Herald added a subscriber: JDevlieghere.
jankratochvil requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

In D98289#inline-939112  
@dblaikie said:

> Perhaps this could be more informative about what makes the range list index 
> of 0 invalid? "index 0 out of range of range list table (with range list base 
> 0xXXX) with offset entry count of XX (valid indexes 0-(XX-1))" Maybe that's 
> too verbose/not worth worrying about since this'll only be relevant to DWARF 
> producers trying to debug their DWARFv5, maybe no one will ever see this 
> message in practice. Just a thought.

If this is OK I will need to submit the LLVM part separately.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102851

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
  llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h

Index: llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
===
--- llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
@@ -94,6 +94,7 @@
   uint8_t getAddrSize() const { return HeaderData.AddrSize; }
   uint64_t getLength() const { return HeaderData.Length; }
   uint16_t getVersion() const { return HeaderData.Version; }
+  uint32_t getOffsetEntryCount() const { return HeaderData.OffsetEntryCount; }
   StringRef getSectionName() const { return SectionName; }
   StringRef getListTypeString() const { return ListTypeString; }
   dwarf::DwarfFormat getFormat() const { return Format; }
@@ -175,6 +176,7 @@
 
   uint64_t getHeaderOffset() const { return Header.getHeaderOffset(); }
   uint8_t getAddrSize() const { return Header.getAddrSize(); }
+  uint32_t getOffsetEntryCount() const { return Header.getOffsetEntryCount(); }
   dwarf::DwarfFormat getFormat() const { return Header.getFormat(); }
 
   void dump(DWARFDataExtractor Data, raw_ostream &OS,
Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
===
--- lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
+++ lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
@@ -21,7 +21,7 @@
 # RUN:   -o exit 2>&1 | FileCheck --check-prefix=RNGLISTX %s
 
 # RNGLISTX-LABEL: image lookup -v -s lookup_rnglists
-# RNGLISTX: error: {{.*}} : DW_FORM_rnglistx cannot be used without DW_AT_rnglists_base
+# RNGLISTX: error: {{.*}} {0x003f}: DIE has DW_AT_ranges(0x0) attribute, but range extraction failed (: DW_FORM_rnglistx cannot be used without DW_AT_rnglists_base), please file a bug and attach the file at the start of this error message
 
 # RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj \
 # RUN:   --defsym RNGLISTX=0 --defsym RNGLISTBASE=0 %s > %t-rnglistbase
@@ -29,7 +29,7 @@
 # RUN:   -o exit 2>&1 | FileCheck --check-prefix=RNGLISTBASE %s
 
 # RNGLISTBASE-LABEL: image lookup -v -s lookup_rnglists
-# RNGLISTBASE: error: {{.*}}-rnglistbase {0x0043}: DIE has DW_AT_ranges(0x0) attribute, but range extraction failed (invalid range list table index 0), please file a bug and attach the file at the start of this error message
+# RNGLISTBASE: error: {{.*}}-rnglistbase {0x0043}: DIE has DW_AT_ranges(0x0) attribute, but range extraction failed (invalid range list table index 0; OffsetEntryCount is 0, DW_AT_rnglists_base is 12), please file a bug and attach the file at the start of this error message
 
 .text
 rnglists:
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -235,7 +235,7 @@
   /// Return a rangelist's offset based on an index. The index designates
   /// an entry in the rangelist table's offset array and is supplied by
   /// DW_FORM_rnglistx.
-  llvm::Optional GetRnglistOffset(uint32_t Index);
+  llvm::Expected GetRnglistOffset(uint32_t Index);
 
   llvm::Optional GetLoclistOffset(uint32_t Index) {
 if (!m_loclist_table_header)
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -507,19 +507,23 @@
 }
 
 // This function is called only for DW_FORM_rnglistx.
-llvm::Optional DWARFUnit::GetRnglistOffset(uint32_t Index) {
+llvm::Expected DWARFUnit::GetRnglistOffset(uint32_t Index) {
   if (!GetRnglist())
-return llvm::None;
-  if (!m_ranges_base) {
-GetSymbolFileDWARF().GetObjectFile()->GetM

[Lldb-commits] [PATCH] D98289: [lldb] 2/2: Fix DW_AT_ranges DW_FORM_sec_offset not using DW_AT_rnglists_base (used by GCC)

2021-05-20 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil marked an inline comment as done.
jankratochvil added inline comments.



Comment at: lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s:32
+# RNGLISTBASE-LABEL: image lookup -v -s lookup_rnglists
+# RNGLISTBASE: error: DW_AT_range-DW_FORM_sec_offset.s.tmp-rnglistbase 
{0x0043}: DIE has DW_AT_ranges(0x0) attribute, but range extraction failed 
(invalid range list table index 0), please file a bug and attach the file at 
the start of this error message
+

jankratochvil wrote:
> dblaikie wrote:
> > Perhaps this could be more informative about what makes the range list 
> > index of 0 invalid? "index 0 out of range of range list table (with range 
> > list base 0xXXX) with offset entry count of XX (valid indexes 0-(XX-1))" 
> > Maybe that's too verbose/not worth worrying about since this'll only be 
> > relevant to DWARF producers trying to debug their DWARFv5, maybe no one 
> > will ever see this message in practice. Just a thought.
> I have written it to my TODO list as it is orthogonal to this patch.
This is now implemented by D102851.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98289

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


[Lldb-commits] [PATCH] D102833: [debugserver]Add platform cache support to improve performance.Under BigSur 11.3 this function causes a performance loss of 0.68s per execution.

2021-05-20 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102833

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


[Lldb-commits] [PATCH] D102833: [debugserver]Add platform cache support to improve performance.Under BigSur 11.3 this function causes a performance loss of 0.68s per execution.

2021-05-20 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

Please let me know if you want me to land this for you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102833

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


[Lldb-commits] [PATCH] D102833: [debugserver]Add platform cache support to improve performance.Under BigSur 11.3 this function causes a performance loss of 0.68s per execution.

2021-05-20 Thread Jason Molenda via Phabricator via lldb-commits
jasonmolenda accepted this revision.
jasonmolenda added a comment.

LGTM, thanks for doing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102833

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


[Lldb-commits] [PATCH] D102851: [lldb] Improve invalid DWARF DW_AT_ranges error reporting

2021-05-20 Thread David Blaikie via Phabricator via lldb-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Looks good to me - at least includes more values from the file to point to the 
problem. Though phrasing might be better (I guess some other code prints the 
"DW_AT_ranges(0x0) attribute" part, which to me seems a bit weird (doesn't 
include the form, which might be useful for instance) and the ": " 
prefix on the "DW_FORM_rnglistx cannot be used" part is maybe a bit of a 
strange way to print the CU offset (nothing in the diagnostic says what this 
number is) - maybe the higher level error handling could print these high level 
details out as a suffix ("Failure in CU that begins at offset , in DIE at 
offset , at attribute DW_AT_*, encoded with DW_FORM_*, with value blah").

But probably not a big deal - if someone's getting sufficiently bogus DWARF to 
reach this, they can probably figure it out. Maybe other LLDB folks have some 
ideas about how best to structure the error handling more generally in this 
regard.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102851

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


[Lldb-commits] [PATCH] D102851: [lldb] Improve invalid DWARF DW_AT_ranges error reporting

2021-05-20 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 346801.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102851

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
  llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h

Index: llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
===
--- llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
@@ -94,6 +94,7 @@
   uint8_t getAddrSize() const { return HeaderData.AddrSize; }
   uint64_t getLength() const { return HeaderData.Length; }
   uint16_t getVersion() const { return HeaderData.Version; }
+  uint32_t getOffsetEntryCount() const { return HeaderData.OffsetEntryCount; }
   StringRef getSectionName() const { return SectionName; }
   StringRef getListTypeString() const { return ListTypeString; }
   dwarf::DwarfFormat getFormat() const { return Format; }
@@ -175,6 +176,7 @@
 
   uint64_t getHeaderOffset() const { return Header.getHeaderOffset(); }
   uint8_t getAddrSize() const { return Header.getAddrSize(); }
+  uint32_t getOffsetEntryCount() const { return Header.getOffsetEntryCount(); }
   dwarf::DwarfFormat getFormat() const { return Header.getFormat(); }
 
   void dump(DWARFDataExtractor Data, raw_ostream &OS,
Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
===
--- lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
+++ lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
@@ -21,7 +21,7 @@
 # RUN:   -o exit 2>&1 | FileCheck --check-prefix=RNGLISTX %s
 
 # RNGLISTX-LABEL: image lookup -v -s lookup_rnglists
-# RNGLISTX: error: {{.*}} : DW_FORM_rnglistx cannot be used without DW_AT_rnglists_base
+# RNGLISTX: error: {{.*}} {0x003f}: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0) attribute, but range extraction failed (DW_FORM_rnglistx cannot be used without DW_AT_rnglists_base for CU at 0x), please file a bug and attach the file at the start of this error message
 
 # RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj \
 # RUN:   --defsym RNGLISTX=0 --defsym RNGLISTBASE=0 %s > %t-rnglistbase
@@ -29,7 +29,7 @@
 # RUN:   -o exit 2>&1 | FileCheck --check-prefix=RNGLISTBASE %s
 
 # RNGLISTBASE-LABEL: image lookup -v -s lookup_rnglists
-# RNGLISTBASE: error: {{.*}}-rnglistbase {0x0043}: DIE has DW_AT_ranges(0x0) attribute, but range extraction failed (invalid range list table index 0), please file a bug and attach the file at the start of this error message
+# RNGLISTBASE: error: {{.*}}-rnglistbase {0x0043}: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0) attribute, but range extraction failed (invalid range list table index 0; OffsetEntryCount is 0, DW_AT_rnglists_base is 12), please file a bug and attach the file at the start of this error message
 
 .text
 rnglists:
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -235,7 +235,7 @@
   /// Return a rangelist's offset based on an index. The index designates
   /// an entry in the rangelist table's offset array and is supplied by
   /// DW_FORM_rnglistx.
-  llvm::Optional GetRnglistOffset(uint32_t Index);
+  llvm::Expected GetRnglistOffset(uint32_t Index);
 
   llvm::Optional GetLoclistOffset(uint32_t Index) {
 if (!m_loclist_table_header)
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -507,19 +507,23 @@
 }
 
 // This function is called only for DW_FORM_rnglistx.
-llvm::Optional DWARFUnit::GetRnglistOffset(uint32_t Index) {
+llvm::Expected DWARFUnit::GetRnglistOffset(uint32_t Index) {
   if (!GetRnglist())
-return llvm::None;
-  if (!m_ranges_base) {
-GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-"%8.8x: DW_FORM_rnglistx cannot be used without DW_AT_rnglists_base",
-GetOffset());
-return llvm::None;
-  }
+return llvm::createStringError(errc::invalid_argument,
+   "missing or invalid range list table");
+  if (!m_ranges_base)
+return llvm::createStringError(errc::invalid_argument,
+   "DW_FORM_rnglistx cannot be used without "
+   "DW_AT_rnglists_base for CU at 0x%8.8x",
+   GetOffset());
   if (llvm::Optional off = GetRnglist()->getOffsetEntry(

[Lldb-commits] [PATCH] D102851: [lldb] Improve invalid DWARF DW_AT_ranges error reporting

2021-05-20 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil requested review of this revision.
jankratochvil added a comment.

Is the message format OK now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102851

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


[Lldb-commits] [PATCH] D102851: [lldb] Improve invalid DWARF DW_AT_ranges error reporting

2021-05-20 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 346807.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102851

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
  lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s
  llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h

Index: llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
===
--- llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
@@ -94,6 +94,7 @@
   uint8_t getAddrSize() const { return HeaderData.AddrSize; }
   uint64_t getLength() const { return HeaderData.Length; }
   uint16_t getVersion() const { return HeaderData.Version; }
+  uint32_t getOffsetEntryCount() const { return HeaderData.OffsetEntryCount; }
   StringRef getSectionName() const { return SectionName; }
   StringRef getListTypeString() const { return ListTypeString; }
   dwarf::DwarfFormat getFormat() const { return Format; }
@@ -175,6 +176,7 @@
 
   uint64_t getHeaderOffset() const { return Header.getHeaderOffset(); }
   uint8_t getAddrSize() const { return Header.getAddrSize(); }
+  uint32_t getOffsetEntryCount() const { return Header.getOffsetEntryCount(); }
   dwarf::DwarfFormat getFormat() const { return Header.getFormat(); }
 
   void dump(DWARFDataExtractor Data, raw_ostream &OS,
Index: lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s
===
--- lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s
+++ lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s
@@ -1,7 +1,7 @@
 # RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t
 # RUN: %lldb %t -o "image lookup -v -s lookup_ranges" -o exit 2>&1 | FileCheck %s
 
-# CHECK: DIE has DW_AT_ranges(0x47) attribute, but range extraction failed (No debug_ranges section),
+# CHECK: DIE has DW_AT_ranges(DW_FORM_sec_offset 0x47) attribute, but range extraction failed (No debug_ranges section),
 # CHECK:  Function: id = {0x001c}, name = "ranges", range = [0x-0x0004)
 # CHECK:Blocks: id = {0x001c}, range = [0x-0x0004)
 
Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
===
--- lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
+++ lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
@@ -21,7 +21,7 @@
 # RUN:   -o exit 2>&1 | FileCheck --check-prefix=RNGLISTX %s
 
 # RNGLISTX-LABEL: image lookup -v -s lookup_rnglists
-# RNGLISTX: error: {{.*}} : DW_FORM_rnglistx cannot be used without DW_AT_rnglists_base
+# RNGLISTX: error: {{.*}} {0x003f}: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0) attribute, but range extraction failed (DW_FORM_rnglistx cannot be used without DW_AT_rnglists_base for CU at 0x), please file a bug and attach the file at the start of this error message
 
 # RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj \
 # RUN:   --defsym RNGLISTX=0 --defsym RNGLISTBASE=0 %s > %t-rnglistbase
@@ -29,7 +29,7 @@
 # RUN:   -o exit 2>&1 | FileCheck --check-prefix=RNGLISTBASE %s
 
 # RNGLISTBASE-LABEL: image lookup -v -s lookup_rnglists
-# RNGLISTBASE: error: {{.*}}-rnglistbase {0x0043}: DIE has DW_AT_ranges(0x0) attribute, but range extraction failed (invalid range list table index 0), please file a bug and attach the file at the start of this error message
+# RNGLISTBASE: error: {{.*}}-rnglistbase {0x0043}: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0) attribute, but range extraction failed (invalid range list table index 0; OffsetEntryCount is 0, DW_AT_rnglists_base is 12), please file a bug and attach the file at the start of this error message
 
 .text
 rnglists:
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -235,7 +235,7 @@
   /// Return a rangelist's offset based on an index. The index designates
   /// an entry in the rangelist table's offset array and is supplied by
   /// DW_FORM_rnglistx.
-  llvm::Optional GetRnglistOffset(uint32_t Index);
+  llvm::Expected GetRnglistOffset(uint32_t Index);
 
   llvm::Optional GetLoclistOffset(uint32_t Index) {
 if (!m_loclist_table_header)
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -507,19 +507,23 @@
 }
 
 // This func

[Lldb-commits] [PATCH] D102851: [lldb] Improve invalid DWARF DW_AT_ranges error reporting

2021-05-20 Thread David Blaikie via Phabricator via lldb-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Yeah, looks pretty good!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102851

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


[Lldb-commits] [PATCH] D102092: [lldb] Enable -Wmisleading-indentation

2021-05-20 Thread Dave Lee via Phabricator via lldb-commits
kastiglione added a comment.

@thakis thanks for pointing that out. I had tried `-Wall` using the clang 
included with the latest version of Xcode, and that does not enable 
`-Wmisleading-indentation`. I see from the compiler explorer that recent clang 
versions do include misleading indentation diagnostics with `-Wall`. It seems 
worth keeping in until an Xcode release includes it with `-Wall`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102092

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


[Lldb-commits] [lldb] 6d19c84 - [lldb] Improve invalid DWARF DW_AT_ranges error reporting

2021-05-20 Thread Jan Kratochvil via lldb-commits

Author: Jan Kratochvil
Date: 2021-05-20T21:37:01+02:00
New Revision: 6d19c84cd90369de5cda37f9a7a721e1cd9d0cb8

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

LOG: [lldb] Improve invalid DWARF DW_AT_ranges error reporting

In D98289#inline-939112 @dblaikie said:
  Perhaps this could be more informative about what makes the range list
  index of 0 invalid? "index 0 out of range of range list table (with
  range list base 0xXXX) with offset entry count of XX (valid indexes
  0-(XX-1))" Maybe that's too verbose/not worth worrying about since
  this'll only be relevant to DWARF producers trying to debug their
  DWARFv5, maybe no one will ever see this message in practice. Just
  a thought.

Reviewed By: dblaikie

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s
llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 9fdd95b45bc7f..a71babaadd1b2 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -214,11 +214,12 @@ static DWARFRangeList GetRangesOrReportError(DWARFUnit 
&unit,
   if (expected_ranges)
 return std::move(*expected_ranges);
   unit.GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-  "{0x%8.8x}: DIE has DW_AT_ranges(0x%" PRIx64 ") attribute, but "
+  "{0x%8.8x}: DIE has DW_AT_ranges(%s 0x%" PRIx64 ") attribute, but "
   "range extraction failed (%s), please file a bug "
   "and attach the file at the start of this error message",
-  die.GetOffset(), value.Unsigned(),
-  toString(expected_ranges.takeError()).c_str());
+  die.GetOffset(),
+  llvm::dwarf::FormEncodingString(value.Form()).str().c_str(),
+  value.Unsigned(), toString(expected_ranges.takeError()).c_str());
   return DWARFRangeList();
 }
 

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index f47a044726f54..62c61ed657f0b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -507,19 +507,23 @@ const llvm::Optional 
&DWARFUnit::GetRnglist() {
 }
 
 // This function is called only for DW_FORM_rnglistx.
-llvm::Optional DWARFUnit::GetRnglistOffset(uint32_t Index) {
+llvm::Expected DWARFUnit::GetRnglistOffset(uint32_t Index) {
   if (!GetRnglist())
-return llvm::None;
-  if (!m_ranges_base) {
-GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-"%8.8x: DW_FORM_rnglistx cannot be used without DW_AT_rnglists_base",
-GetOffset());
-return llvm::None;
-  }
+return llvm::createStringError(errc::invalid_argument,
+   "missing or invalid range list table");
+  if (!m_ranges_base)
+return llvm::createStringError(errc::invalid_argument,
+   "DW_FORM_rnglistx cannot be used without "
+   "DW_AT_rnglists_base for CU at 0x%8.8x",
+   GetOffset());
   if (llvm::Optional off = GetRnglist()->getOffsetEntry(
   m_dwarf.GetDWARFContext().getOrLoadRngListsData().GetAsLLVM(), 
Index))
 return *off + m_ranges_base;
-  return llvm::None;
+  return llvm::createStringError(
+  errc::invalid_argument,
+  "invalid range list table index %u; OffsetEntryCount is %u, "
+  "DW_AT_rnglists_base is %" PRIu64,
+  Index, GetRnglist()->getOffsetEntryCount(), m_ranges_base);
 }
 
 void DWARFUnit::SetStrOffsetsBase(dw_offset_t str_offsets_base) {
@@ -996,12 +1000,8 @@ DWARFUnit::FindRnglistFromOffset(dw_offset_t offset) {
 
 llvm::Expected
 DWARFUnit::FindRnglistFromIndex(uint32_t index) {
-  if (llvm::Optional offset = GetRnglistOffset(index))
-return FindRnglistFromOffset(*offset);
-  if (GetRnglist())
-return llvm::createStringError(errc::invalid_argument,
-   "invalid range list table index %d", index);
-
-  return llvm::createStringError(errc::invalid_argument,
- "missing or invalid range list table");
+  llvm::Expected maybe_offset = GetRnglistOffset(index);
+  if (!maybe_offset)
+return maybe_offset.takeError();
+  return FindRnglistFromOffset(*maybe_offset);
 }

diff  --git a/lldb/source/Plugins

[Lldb-commits] [PATCH] D102851: [lldb] Improve invalid DWARF DW_AT_ranges error reporting

2021-05-20 Thread Jan Kratochvil 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 rG6d19c84cd903: [lldb] Improve invalid DWARF DW_AT_ranges 
error reporting (authored by jankratochvil).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102851

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
  lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s
  llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h

Index: llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
===
--- llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFListTable.h
@@ -94,6 +94,7 @@
   uint8_t getAddrSize() const { return HeaderData.AddrSize; }
   uint64_t getLength() const { return HeaderData.Length; }
   uint16_t getVersion() const { return HeaderData.Version; }
+  uint32_t getOffsetEntryCount() const { return HeaderData.OffsetEntryCount; }
   StringRef getSectionName() const { return SectionName; }
   StringRef getListTypeString() const { return ListTypeString; }
   dwarf::DwarfFormat getFormat() const { return Format; }
@@ -175,6 +176,7 @@
 
   uint64_t getHeaderOffset() const { return Header.getHeaderOffset(); }
   uint8_t getAddrSize() const { return Header.getAddrSize(); }
+  uint32_t getOffsetEntryCount() const { return Header.getOffsetEntryCount(); }
   dwarf::DwarfFormat getFormat() const { return Header.getFormat(); }
 
   void dump(DWARFDataExtractor Data, raw_ostream &OS,
Index: lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s
===
--- lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s
+++ lldb/test/Shell/SymbolFile/DWARF/x86/debug_ranges-missing-section.s
@@ -1,7 +1,7 @@
 # RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t
 # RUN: %lldb %t -o "image lookup -v -s lookup_ranges" -o exit 2>&1 | FileCheck %s
 
-# CHECK: DIE has DW_AT_ranges(0x47) attribute, but range extraction failed (No debug_ranges section),
+# CHECK: DIE has DW_AT_ranges(DW_FORM_sec_offset 0x47) attribute, but range extraction failed (No debug_ranges section),
 # CHECK:  Function: id = {0x001c}, name = "ranges", range = [0x-0x0004)
 # CHECK:Blocks: id = {0x001c}, range = [0x-0x0004)
 
Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
===
--- lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
+++ lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
@@ -21,7 +21,7 @@
 # RUN:   -o exit 2>&1 | FileCheck --check-prefix=RNGLISTX %s
 
 # RNGLISTX-LABEL: image lookup -v -s lookup_rnglists
-# RNGLISTX: error: {{.*}} : DW_FORM_rnglistx cannot be used without DW_AT_rnglists_base
+# RNGLISTX: error: {{.*}} {0x003f}: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0) attribute, but range extraction failed (DW_FORM_rnglistx cannot be used without DW_AT_rnglists_base for CU at 0x), please file a bug and attach the file at the start of this error message
 
 # RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj \
 # RUN:   --defsym RNGLISTX=0 --defsym RNGLISTBASE=0 %s > %t-rnglistbase
@@ -29,7 +29,7 @@
 # RUN:   -o exit 2>&1 | FileCheck --check-prefix=RNGLISTBASE %s
 
 # RNGLISTBASE-LABEL: image lookup -v -s lookup_rnglists
-# RNGLISTBASE: error: {{.*}}-rnglistbase {0x0043}: DIE has DW_AT_ranges(0x0) attribute, but range extraction failed (invalid range list table index 0), please file a bug and attach the file at the start of this error message
+# RNGLISTBASE: error: {{.*}}-rnglistbase {0x0043}: DIE has DW_AT_ranges(DW_FORM_rnglistx 0x0) attribute, but range extraction failed (invalid range list table index 0; OffsetEntryCount is 0, DW_AT_rnglists_base is 12), please file a bug and attach the file at the start of this error message
 
 .text
 rnglists:
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -235,7 +235,7 @@
   /// Return a rangelist's offset based on an index. The index designates
   /// an entry in the rangelist table's offset array and is supplied by
   /// DW_FORM_rnglistx.
-  llvm::Optional GetRnglistOffset(uint32_t Index);
+  llvm::Expected GetRnglistOffset(uint32_t Index);
 
   llvm::Optional GetLoclistOffset(uint32_t Index) {
 if (!m_loclist_table_header)
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===

[Lldb-commits] [PATCH] D102811: [lldb] Move ClangModulesDeclVendor ownership to ClangPersistentVariables from Target

2021-05-20 Thread Alex Langford via Phabricator via lldb-commits
bulbazord updated this revision to Diff 346841.
bulbazord added a comment.

Add helper in ClangASTSource


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102811

Files:
  lldb/include/lldb/Target/Target.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionSourceCode.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Target/CMakeLists.txt
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -2546,23 +2546,6 @@
   return *m_source_manager_up;
 }
 
-ClangModulesDeclVendor *Target::GetClangModulesDeclVendor() {
-  static std::mutex s_clang_modules_decl_vendor_mutex; // If this is contended
-   // we can make it
-   // per-target
-
-  {
-std::lock_guard guard(s_clang_modules_decl_vendor_mutex);
-
-if (!m_clang_modules_decl_vendor_up) {
-  m_clang_modules_decl_vendor_up.reset(
-  ClangModulesDeclVendor::Create(*this));
-}
-  }
-
-  return m_clang_modules_decl_vendor_up.get();
-}
-
 Target::StopHookSP Target::CreateStopHook(StopHook::StopHookKind kind) {
   lldb::user_id_t new_uid = ++m_stop_hook_next_id;
   Target::StopHookSP stop_hook_sp;
Index: lldb/source/Target/CMakeLists.txt
===
--- lldb/source/Target/CMakeLists.txt
+++ lldb/source/Target/CMakeLists.txt
@@ -81,7 +81,6 @@
 lldbInterpreter
 lldbSymbol
 lldbUtility
-lldbPluginExpressionParserClang
 lldbPluginProcessUtility
 
   LINK_COMPONENTS
Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9653,7 +9653,8 @@
llvm::Triple triple)
 : TypeSystemClang("scratch ASTContext", triple), m_triple(triple),
   m_target_wp(target.shared_from_this()),
-  m_persistent_variables(new ClangPersistentVariables) {
+  m_persistent_variables(
+  new ClangPersistentVariables(target.shared_from_this())) {
   m_scratch_ast_source_up = CreateASTSource();
   m_scratch_ast_source_up->InstallASTContext(*this);
   llvm::IntrusiveRefCntPtr proxy_ast_source(
Index: lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
===
--- lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -990,8 +990,11 @@
   bool result = false;
 
   if (auto *target = exe_scope->CalculateTarget().get()) {
-if (auto *clang_modules_decl_vendor =
-target->GetClangModulesDeclVendor()) {
+auto *persistent_vars = llvm::cast(
+target->GetPersistentExpressionStateForLanguage(
+lldb::eLanguageTypeC));
+if (std::shared_ptr clang_modules_decl_vendor =
+persistent_vars->GetClangModulesDeclVendor()) {
   ConstString key_cs(key);
   auto types = clang_modules_decl_vendor->FindTypes(
   key_cs, /*max_matches*/ UINT32_MAX);
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -352,10 +352,6 @@
 
 static void SetupDeclVendor(ExecutionContext &exe_ctx, Target *target,
 DiagnosticManager &diagnostic_manager) {
-  ClangModulesDeclVendor *decl_vendor = target->GetClangModulesDeclVendor();
-  if (!decl_vendor)
-return;
-
   if (!target->GetEnableAutoImportClangModules())
 return;
 
@@ -364,6 +360,11 @@
   if (!persistent_state)
 return;
 
+  std::shared_ptr decl_vendor =
+  persistent_state->GetClangModulesDeclVendor();
+  if (!decl_vendor)
+return;
+
   StackFrame *frame = exe_ctx.GetFramePtr();
   if (!frame)
 return;
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.h
=

[Lldb-commits] [PATCH] D102872: Fix lldb-server build failure on mips

2021-05-20 Thread Khem Raj via Phabricator via lldb-commits
raj.khem created this revision.
raj.khem added a project: LLDB.
Herald added subscribers: JDevlieghere, atanasyan, arichardson, sdardis.
raj.khem requested review of this revision.
Herald added a subscriber: lldb-commits.

This helps fixing lldb-server build regression

> /mnt/b/yoe/master/build/tmp/work/mips32r2-yoe-linux-musl/clang/13.0.0-r0/recipe-sysroot-native/usr/bin/mips-yoe-linux-musl/mips-yoe-linux-musl-ld:
>  lib/liblldbPluginProcessLinux.a(NativeThreadLinux.cpp.o): in function 
> `lldb_private::process_linux::NativeThreadLinux::NativeThreadLinux(lldb_private::process_linux::NativeProcessLinux&,
>  unsigned long long)':
> NativeThreadLinux.cpp:(.text._ZN12lldb_private13process_linux17NativeThreadLinuxC2ERNS0_18NativeProcessLinuxEy+0x74):
>  undefined reference to 
> `lldb_private::process_linux::NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(lldb_private::ArchSpec
>  const&, lldb_private::process_linux::NativeThreadLinux&)'
> /mnt/b/yoe/master/build/tmp/work/mips32r2-yoe-linux-musl/clang/13.0.0-r0/recipe-sysroot-native/usr/bin/mips-yoe-linux-musl/mips-yoe-linux-musl-ld:
>  
> NativeThreadLinux.cpp:(.text._ZN12lldb_private13process_linux17NativeThreadLinuxC2ERNS0_18NativeProcessLinuxEy+0x7c):
>  undefined reference to 
> `lldb_private::process_linux::NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(lldb_private::ArchSpec
>  const&, lldb_private::process_linux::NativeThreadLinux&)'
> clang-13: error: linker command failed with exit code 1 (use -v to see 
> invocation)




Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102872

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h


Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
@@ -26,7 +26,8 @@
   // variant should be compiled into the final executable.
   static std::unique_ptr
   CreateHostNativeRegisterContextLinux(const ArchSpec &target_arch,
-   NativeThreadLinux &native_thread);
+   NativeThreadLinux &native_thread)
+  { return 0; }
 
   // Invalidates cached values in register context data structures
   virtual void InvalidateAllRegisters(){}


Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.h
@@ -26,7 +26,8 @@
   // variant should be compiled into the final executable.
   static std::unique_ptr
   CreateHostNativeRegisterContextLinux(const ArchSpec &target_arch,
-   NativeThreadLinux &native_thread);
+   NativeThreadLinux &native_thread)
+	   { return 0; }
 
   // Invalidates cached values in register context data structures
   virtual void InvalidateAllRegisters(){}
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D102811: [lldb] Move ClangModulesDeclVendor ownership to ClangPersistentVariables from Target

2021-05-20 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor accepted this revision.
teemperor added a comment.
This revision is now accepted and ready to land.

LGTM. Soon LLDB will be as nicely layered (and maybe as tasty) as some good 
Schichttorte


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102811

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


[Lldb-commits] [PATCH] D102866: [lldb][intel-pt] Remove old plugin

2021-05-20 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

I would be ok with this. Can you track down the original author and add them to 
the review of this to be sure they aren't using it anymore, and if they need 
tracing that they have everything they need with your new functionality?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102866

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


[Lldb-commits] [PATCH] D102872: Fix lldb-server build failure on mips

2021-05-20 Thread Khem Raj via Phabricator via lldb-commits
raj.khem updated this revision to Diff 346855.

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

https://reviews.llvm.org/D102872

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp


Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
@@ -23,6 +23,13 @@
   return m_thread.GetProcess().GetByteOrder();
 }
 
+std::unique_ptr
+NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(
+  const ArchSpec &target_arch,
+   NativeThreadLinux &native_thread) {
+   return 0;
+}
+
 Status NativeRegisterContextLinux::ReadRegisterRaw(uint32_t reg_index,
RegisterValue ®_value) {
   const RegisterInfo *const reg_info = GetRegisterInfoAtIndex(reg_index);


Index: lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
===
--- lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
+++ lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux.cpp
@@ -23,6 +23,13 @@
   return m_thread.GetProcess().GetByteOrder();
 }
 
+std::unique_ptr
+NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(
+	   const ArchSpec &target_arch,
+   NativeThreadLinux &native_thread) {
+	return 0;
+}
+
 Status NativeRegisterContextLinux::ReadRegisterRaw(uint32_t reg_index,
RegisterValue ®_value) {
   const RegisterInfo *const reg_info = GetRegisterInfoAtIndex(reg_index);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D102866: [lldb][intel-pt] Remove old plugin

2021-05-20 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

I'll contact them again. Last time I did they didn't reply. And btw, this 
feature was broken for years and last year i revived this plugin, so I imagine 
no one was using it. And in terms of features, the new implementation supports 
the same features


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102866

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


[Lldb-commits] [PATCH] D102889: [lldb] Match test dependencies name to other LLVM projects.

2021-05-20 Thread Daniel Rodríguez Troitiño via Phabricator via lldb-commits
drodriguez created this revision.
drodriguez added reviewers: JDevlieghere, labath, xiaobai.
Herald added a subscriber: mgorny.
drodriguez requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Other LLVM projects use the suffix `-depends` for the test dependencies,
however LLDB uses `-deps` and seems to be the only project under the
LLVM to do so.

In order to make the projects more homogeneous, switch all the
references to `lldb-test-deps` to `lldb-test-depends`.

Additionally, provide a compatibility target with the old name and
depending on the new name, in order to not break anyone workflow.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102889

Files:
  lldb/test/API/CMakeLists.txt
  lldb/test/CMakeLists.txt
  lldb/test/Shell/CMakeLists.txt
  lldb/test/Unit/CMakeLists.txt
  lldb/utils/lldb-dotest/CMakeLists.txt
  lldb/utils/lldb-repro/CMakeLists.txt

Index: lldb/utils/lldb-repro/CMakeLists.txt
===
--- lldb/utils/lldb-repro/CMakeLists.txt
+++ lldb/utils/lldb-repro/CMakeLists.txt
@@ -1,5 +1,5 @@
 add_custom_target(lldb-repro)
-add_dependencies(lldb-repro lldb-test-deps)
+add_dependencies(lldb-repro lldb-test-depends)
 set_target_properties(lldb-repro PROPERTIES FOLDER "lldb utils")
 
 # Generate lldb-repro Python script for each build mode.
Index: lldb/utils/lldb-dotest/CMakeLists.txt
===
--- lldb/utils/lldb-dotest/CMakeLists.txt
+++ lldb/utils/lldb-dotest/CMakeLists.txt
@@ -1,6 +1,6 @@
 # Make lldb-dotest a custom target.
 add_custom_target(lldb-dotest)
-add_dependencies(lldb-dotest lldb-test-deps)
+add_dependencies(lldb-dotest lldb-test-depends)
 set_target_properties(lldb-dotest PROPERTIES FOLDER "lldb utils")
 
 get_property(LLDB_DOTEST_ARGS GLOBAL PROPERTY LLDB_DOTEST_ARGS_PROPERTY)
Index: lldb/test/Unit/CMakeLists.txt
===
--- lldb/test/Unit/CMakeLists.txt
+++ lldb/test/Unit/CMakeLists.txt
@@ -1,5 +1,5 @@
 add_custom_target(lldb-unit-test-deps)
-add_dependencies(lldb-unit-test-deps lldb-test-deps)
+add_dependencies(lldb-unit-test-deps lldb-test-depends)
 
 add_lit_testsuites(LLDB-UNIT
   ${CMAKE_CURRENT_SOURCE_DIR}
Index: lldb/test/Shell/CMakeLists.txt
===
--- lldb/test/Shell/CMakeLists.txt
+++ lldb/test/Shell/CMakeLists.txt
@@ -1,5 +1,5 @@
 add_custom_target(lldb-shell-test-deps)
-add_dependencies(lldb-shell-test-deps lldb-test-deps)
+add_dependencies(lldb-shell-test-deps lldb-test-depends)
 
 add_lit_testsuites(LLDB-SHELL
   ${CMAKE_CURRENT_SOURCE_DIR}
Index: lldb/test/CMakeLists.txt
===
--- lldb/test/CMakeLists.txt
+++ lldb/test/CMakeLists.txt
@@ -31,12 +31,16 @@
 string(REPLACE ${CMAKE_CFG_INTDIR} ${LLVM_BUILD_MODE} LLDB_TOOLS_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
 
 # Create a custom target to track test dependencies.
+add_custom_target(lldb-test-depends)
+set_target_properties(lldb-test-depends PROPERTIES FOLDER "lldb misc")
+
+# Create an alias for the legacy name of lldb-test-depends
 add_custom_target(lldb-test-deps)
-set_target_properties(lldb-test-deps PROPERTIES FOLDER "lldb misc")
+add_dependencies(lldb-test-deps lldb-test-depends)
 
 function(add_lldb_test_dependency)
   foreach(dependency ${ARGN})
-add_dependencies(lldb-test-deps ${dependency})
+add_dependencies(lldb-test-depends ${dependency})
   endforeach()
 endfunction(add_lldb_test_dependency)
 
@@ -201,7 +205,7 @@
   ${CMAKE_CURRENT_BINARY_DIR}/Shell
   PARAMS "lldb-run-with-repro=capture"
   EXCLUDE_FROM_CHECK_ALL
-  DEPENDS lldb-test-deps)
+  DEPENDS lldb-test-depends)
 
 # Add a lit test suite that runs the API & shell test by replaying a
 # reproducer.
@@ -211,7 +215,7 @@
   ${CMAKE_CURRENT_BINARY_DIR}/Shell
   PARAMS "lldb-run-with-repro=replay"
   EXCLUDE_FROM_CHECK_ALL
-  DEPENDS lldb-test-deps)
+  DEPENDS lldb-test-depends)
 add_dependencies(check-lldb-reproducers check-lldb-reproducers-capture)
 
 if(LLDB_BUILT_STANDALONE)
Index: lldb/test/API/CMakeLists.txt
===
--- lldb/test/API/CMakeLists.txt
+++ lldb/test/API/CMakeLists.txt
@@ -1,5 +1,5 @@
 add_custom_target(lldb-api-test-deps)
-add_dependencies(lldb-api-test-deps lldb-test-deps)
+add_dependencies(lldb-api-test-deps lldb-test-depends)
 
 add_lit_testsuites(LLDB-API
   ${CMAKE_CURRENT_SOURCE_DIR}
@@ -17,7 +17,7 @@
 COMMENT "${comment}"
 USES_TERMINAL
 )
-  add_dependencies(${name} lldb-test-deps)
+  add_dependencies(${name} lldb-test-depends)
 endfunction()
 
 # The default architecture with which to compile test executables is the
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D102889: [lldb] Match test dependencies name to other LLVM projects.

2021-05-20 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102889

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


[Lldb-commits] [PATCH] D102833: [debugserver]Add platform cache support to improve performance.Under BigSur 11.3 this function causes a performance loss of 0.68s per execution.

2021-05-20 Thread kuperxu via Phabricator via lldb-commits
kuperxu added a comment.

I don't have permission to commit, please land this code.
Thank you @JDevlieghere


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102833

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


[Lldb-commits] [PATCH] D102866: [lldb][intel-pt] Remove old plugin

2021-05-20 Thread walter erquinigo via Phabricator via lldb-commits
wallace added a comment.

Btw, lldb-server for a few months hasn't been supporting the functionalities 
required by the old plugin, and as no one has complained, I imagine it's been 
not actively used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102866

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


[Lldb-commits] [lldb] 8dd1060 - [debugserver] Add platform cache support to improve performance.

2021-05-20 Thread Jonas Devlieghere via lldb-commits

Author: kuperxu
Date: 2021-05-20T19:10:46-07:00
New Revision: 8dd106028b1533f0de03a1ffb4ea0dce40b5a2ff

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

LOG: [debugserver] Add platform cache support to improve performance.

The dyld SPI used by debugserver (_dyld_process_info_create) has become
much slower in macOS BigSur 11.3 causing a significant performance
regression when attaching. This commit mitigates that by caching the
result when calling the SPI to compute the platform.

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

Added: 


Modified: 
lldb/tools/debugserver/source/MacOSX/MachProcess.h
lldb/tools/debugserver/source/MacOSX/MachProcess.mm

Removed: 




diff  --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.h 
b/lldb/tools/debugserver/source/MacOSX/MachProcess.h
index b295dfecec41..33c3d628a7a0 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.h
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.h
@@ -252,6 +252,7 @@ class MachProcess {
  struct mach_o_information &inf);
   JSONGenerator::ObjectSP FormatDynamicLibrariesIntoJSON(
   const std::vector &image_infos);
+  uint32_t GetPlatform();
   /// Get the runtime platform from DYLD via SPI.
   uint32_t GetProcessPlatformViaDYLDSPI();
   /// Use the dyld SPI present in macOS 10.12, iOS 10, tvOS 10,
@@ -378,6 +379,7 @@ class MachProcess {
 
   pid_t m_pid;   // Process ID of child process
   cpu_type_t m_cpu_type; // The CPU type of this process
+  uint32_t m_platform;   // The platform of this process
   int m_child_stdin;
   int m_child_stdout;
   int m_child_stderr;

diff  --git a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm 
b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
index 0a6ef6161711..7eab2c6d185f 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ b/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -701,7 +701,7 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary 
*options,
   // DYLD_FORCE_PLATFORM=6. In that case, force the platform to
   // macCatalyst and use the macCatalyst version of the host OS
   // instead of the macOS deployment target.
-  if (is_executable && GetProcessPlatformViaDYLDSPI() == PLATFORM_MACCATALYST) 
{
+  if (is_executable && GetPlatform() == PLATFORM_MACCATALYST) {
 info.platform = PLATFORM_MACCATALYST;
 std::string catalyst_version = GetMacCatalystVersionString();
 const char *major = catalyst_version.c_str();
@@ -1094,6 +1094,12 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary 
*options,
   bool privateCache;
 };
 
+uint32_t MachProcess::GetPlatform() {
+  if (m_platform == 0)
+m_platform = MachProcess::GetProcessPlatformViaDYLDSPI();
+  return m_platform;
+}
+
 uint32_t MachProcess::GetProcessPlatformViaDYLDSPI() {
   kern_return_t kern_ret;
   uint32_t platform = 0;
@@ -1140,7 +1146,7 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary 
*options,
   int pointer_size = GetInferiorAddrSize(pid);
   std::vector image_infos;
   GetAllLoadedBinariesViaDYLDSPI(image_infos);
-  uint32_t platform = GetProcessPlatformViaDYLDSPI();
+  uint32_t platform = GetPlatform();
   const size_t image_count = image_infos.size();
   for (size_t i = 0; i < image_count; i++) {
 GetMachOInformationFromMemory(platform, image_infos[i].load_address,
@@ -1160,7 +1166,7 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary 
*options,
 
   std::vector all_image_infos;
   GetAllLoadedBinariesViaDYLDSPI(all_image_infos);
-  uint32_t platform = GetProcessPlatformViaDYLDSPI();
+  uint32_t platform = GetPlatform();
 
   std::vector image_infos;
   const size_t macho_addresses_count = macho_addresses.size();
@@ -1324,6 +1330,7 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary 
*options,
   // Clear any cached thread list while the pid and task are still valid
 
   m_task.Clear();
+  m_platform = 0;
   // Now clear out all member variables
   m_pid = INVALID_NUB_PROCESS;
   if (!detaching)
@@ -1615,6 +1622,7 @@ static bool FBSAddEventDataToOptions(NSMutableDictionary 
*options,
 
   // NULL our task out as we have already restored all exception ports
   m_task.Clear();
+  m_platform = 0;
 
   // Clear out any notion of the process we once were
   const bool detaching = true;



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


[Lldb-commits] [PATCH] D102833: [debugserver]Add platform cache support to improve performance.Under BigSur 11.3 this function causes a performance loss of 0.68s per execution.

2021-05-20 Thread Jonas Devlieghere 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 rG8dd106028b15: [debugserver] Add platform cache support to 
improve performance. (authored by kuperxu, committed by JDevlieghere).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102833

Files:
  lldb/tools/debugserver/source/MacOSX/MachProcess.h
  lldb/tools/debugserver/source/MacOSX/MachProcess.mm


Index: lldb/tools/debugserver/source/MacOSX/MachProcess.mm
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -701,7 +701,7 @@
   // DYLD_FORCE_PLATFORM=6. In that case, force the platform to
   // macCatalyst and use the macCatalyst version of the host OS
   // instead of the macOS deployment target.
-  if (is_executable && GetProcessPlatformViaDYLDSPI() == PLATFORM_MACCATALYST) 
{
+  if (is_executable && GetPlatform() == PLATFORM_MACCATALYST) {
 info.platform = PLATFORM_MACCATALYST;
 std::string catalyst_version = GetMacCatalystVersionString();
 const char *major = catalyst_version.c_str();
@@ -1094,6 +1094,12 @@
   bool privateCache;
 };
 
+uint32_t MachProcess::GetPlatform() {
+  if (m_platform == 0)
+m_platform = MachProcess::GetProcessPlatformViaDYLDSPI();
+  return m_platform;
+}
+
 uint32_t MachProcess::GetProcessPlatformViaDYLDSPI() {
   kern_return_t kern_ret;
   uint32_t platform = 0;
@@ -1140,7 +1146,7 @@
   int pointer_size = GetInferiorAddrSize(pid);
   std::vector image_infos;
   GetAllLoadedBinariesViaDYLDSPI(image_infos);
-  uint32_t platform = GetProcessPlatformViaDYLDSPI();
+  uint32_t platform = GetPlatform();
   const size_t image_count = image_infos.size();
   for (size_t i = 0; i < image_count; i++) {
 GetMachOInformationFromMemory(platform, image_infos[i].load_address,
@@ -1160,7 +1166,7 @@
 
   std::vector all_image_infos;
   GetAllLoadedBinariesViaDYLDSPI(all_image_infos);
-  uint32_t platform = GetProcessPlatformViaDYLDSPI();
+  uint32_t platform = GetPlatform();
 
   std::vector image_infos;
   const size_t macho_addresses_count = macho_addresses.size();
@@ -1324,6 +1330,7 @@
   // Clear any cached thread list while the pid and task are still valid
 
   m_task.Clear();
+  m_platform = 0;
   // Now clear out all member variables
   m_pid = INVALID_NUB_PROCESS;
   if (!detaching)
@@ -1615,6 +1622,7 @@
 
   // NULL our task out as we have already restored all exception ports
   m_task.Clear();
+  m_platform = 0;
 
   // Clear out any notion of the process we once were
   const bool detaching = true;
Index: lldb/tools/debugserver/source/MacOSX/MachProcess.h
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.h
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.h
@@ -252,6 +252,7 @@
  struct mach_o_information &inf);
   JSONGenerator::ObjectSP FormatDynamicLibrariesIntoJSON(
   const std::vector &image_infos);
+  uint32_t GetPlatform();
   /// Get the runtime platform from DYLD via SPI.
   uint32_t GetProcessPlatformViaDYLDSPI();
   /// Use the dyld SPI present in macOS 10.12, iOS 10, tvOS 10,
@@ -378,6 +379,7 @@
 
   pid_t m_pid;   // Process ID of child process
   cpu_type_t m_cpu_type; // The CPU type of this process
+  uint32_t m_platform;   // The platform of this process
   int m_child_stdin;
   int m_child_stdout;
   int m_child_stderr;


Index: lldb/tools/debugserver/source/MacOSX/MachProcess.mm
===
--- lldb/tools/debugserver/source/MacOSX/MachProcess.mm
+++ lldb/tools/debugserver/source/MacOSX/MachProcess.mm
@@ -701,7 +701,7 @@
   // DYLD_FORCE_PLATFORM=6. In that case, force the platform to
   // macCatalyst and use the macCatalyst version of the host OS
   // instead of the macOS deployment target.
-  if (is_executable && GetProcessPlatformViaDYLDSPI() == PLATFORM_MACCATALYST) {
+  if (is_executable && GetPlatform() == PLATFORM_MACCATALYST) {
 info.platform = PLATFORM_MACCATALYST;
 std::string catalyst_version = GetMacCatalystVersionString();
 const char *major = catalyst_version.c_str();
@@ -1094,6 +1094,12 @@
   bool privateCache;
 };
 
+uint32_t MachProcess::GetPlatform() {
+  if (m_platform == 0)
+m_platform = MachProcess::GetProcessPlatformViaDYLDSPI();
+  return m_platform;
+}
+
 uint32_t MachProcess::GetProcessPlatformViaDYLDSPI() {
   kern_return_t kern_ret;
   uint32_t platform = 0;
@@ -1140,7 +1146,7 @@
   int pointer_size = GetInferiorAddrSize(pid);
   std::vector image_infos;
   GetAllLoadedBinariesViaDYLDSPI(image_infos);
-  uint32_t platform = GetProcessPlatformViaDYLDSPI();
+  uint32_t platform = GetPlatform();
   const size_t image_count = image_infos.size();
   for (size_t i = 0; i < im