[Lldb-commits] [PATCH] D99401: Fix .debug_aranges parsing issues.

2021-03-26 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

When LLVM error handling was introduced to the parsing of the .debug_aranges it 
would cause major issues if any DWARFDebugArangeSet::extract() calls returned 
any errors. The code in DWARFDebugInfo::GetCompileUnitAranges() would end up 
calling DWARFDebugAranges::extract() which would return an error if _any_ 
DWARFDebugArangeSet had any errors, but it default constructed a 
DWARFDebugAranges object into DWARFDebugInfo::m_cu_aranges_up and populated it 
partially, and returned an error prior to finishing much needed functionality 
in the DWARFDebugInfo::GetCompileUnitAranges() function. Subsequent callers to 
this function would see that the DWARFDebugInfo::m_cu_aranges_up was actually 
valid and return this partially populated DWARFDebugAranges reference _and_ it 
would not be sorted or minimized.

This above bugs would cause an incomplete .debug_aranges parsing, it would skip 
manually parsing any compile units for ranges, and would not sort the 
DWARFDebugAranges in m_cu_aranges_up.

This bug would also cause breakpoints set by file and line to fail to set 
correctly if a symbol context for an address could not be resolved properly, 
which the incomplete and unsorted DWARFDebugAranges object that 
DWARFDebugInfo::GetCompileUnitAranges() returned would cause symbol context 
lookups resolved by address (breakpoint address) to fail to find any DWARF 
debug info for a given address.

This patch fixes all of the issues that I found:

- DWARFDebugInfo::GetCompileUnitAranges() no longer returns a 
"llvm::Expected", but just returns a "const 
DWARFDebugAranges &". Why? Because this code contained a fallback that would 
parse all of the valid DWARFDebugArangeSet objects, and would check which 
compile units had valid .debug_aranges set entries, and manually build an 
address ranges table using DWARFUnit::BuildAddressRangeTable(). If we return an 
error because any DWARFDebugArangeSet has any errors, then we don't do any of 
this code. Now we parse all DWARFDebugArangeSet objects that have no errors, if 
any calls to DWARFDebugArangeSet::extract() return errors, we skip that 
DWARFDebugArangeSet so that we can use the fallback call to 
DWARFUnit::BuildAddressRangeTable(). Since 
DWARFDebugInfo::GetCompileUnitAranges() needs to parse what it can from the 
.debug_aranges and build address ranges tables for any compile units that don't 
have any .debug_aranges sets, everything now works as expected.
- Fix an issue where a DWARFDebugArangeSet contains multiple terminator 
entries. The LLVM parser and llvm-dwarfdump properly warn about this because it 
happens with linux compilers and linkers and was the original cause of the bug 
I am fixing here. We now correctly warn about this issue if "log enable dwarf 
info" is enabled, but we continue to parse the DWARFDebugArangeSet correctly so 
we don't lose data that is contained in the .debug_aranges section.
- DWARFDebugAranges::extract() no longer returns a llvm::Error because we need 
to be able to parse all of the valid DWARFDebugArangeSet objects. It also will 
correctly skip a DWARFDebugArangeSet object that has errors in the middle of 
the stream by setting the start offsets of each DWARFDebugArangeSet to be 
calculated by the previous DWARFDebugArangeSet::extract() calculated offset 
that uses the header which contains the length of the DWARFDebugArangeSet. This 
means if do we run into real errors while parsing individual 
DWARFDebugArangeSet objects, we can continue to parse the rest of the validly 
encoded DWARFDebugArangeSet objects in the .debug_aranges section. This will 
allow LLDB to parse DWARF that contains a possibly newer .debug_aranges set 
format than LLDB currently supports because we will error out for the parsing 
of the DWARFDebugArangeSet, but be able to skip to the next DWARFDebugArangeSet 
object using the "DWARFDebugArangeSet.m_header.length" field to calculate the 
next starting offset.

Tests were added to cover all new functionality.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99401

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp

Index: lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
===
--- lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
+++ lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
@@ -347,12 +347,101 @@
   EXPECT_EQ(off, 12U); // Parser should r

[Lldb-commits] [PATCH] D98153: Some FormatEntity.cpp cleanup and unit testing

2021-03-26 Thread Neal via Phabricator via lldb-commits
nealsid updated this revision to Diff 333507.
nealsid added a comment.

Thanks for the review - addressed your comments here (I had to rely on Doxygen 
picking up the type reference automatically because I couldn't get the \see 
syntax to work correctly, though)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98153

Files:
  lldb/include/lldb/Core/FormatEntity.h
  lldb/source/Core/FormatEntity.cpp
  lldb/unittests/Core/CMakeLists.txt
  lldb/unittests/Core/FormatEntityTest.cpp

Index: lldb/unittests/Core/FormatEntityTest.cpp
===
--- /dev/null
+++ lldb/unittests/Core/FormatEntityTest.cpp
@@ -0,0 +1,159 @@
+//===-- FormatEntityTest.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 "lldb/Core/FormatEntity.h"
+#include "lldb/Utility/Status.h"
+
+#include "llvm/ADT/StringRef.h"
+#include "gtest/gtest.h"
+
+using namespace lldb_private;
+
+using Definition = FormatEntity::Entry::Definition;
+using Entry = FormatEntity::Entry;
+
+TEST(FormatEntityTest, DefinitionConstructionNameAndType) {
+  Definition d("foo", FormatEntity::Entry::Type::Invalid);
+
+  EXPECT_EQ(d.name, "foo");
+  EXPECT_EQ(d.string, nullptr);
+  EXPECT_EQ(d.type, FormatEntity::Entry::Type::Invalid);
+  EXPECT_EQ(d.data, 0UL);
+  EXPECT_EQ(d.num_children, 0UL);
+  EXPECT_EQ(d.children, nullptr);
+  EXPECT_FALSE(d.keep_separator);
+}
+
+TEST(FormatEntityTest, DefinitionConstructionNameAndString) {
+  Definition d("foo", "string");
+
+  EXPECT_EQ(d.name, "foo");
+  EXPECT_EQ(d.string, "string");
+  EXPECT_EQ(d.type, FormatEntity::Entry::Type::EscapeCode);
+  EXPECT_EQ(d.data, 0UL);
+  EXPECT_EQ(d.num_children, 0UL);
+  EXPECT_EQ(d.children, nullptr);
+  EXPECT_FALSE(d.keep_separator);
+}
+
+TEST(FormatEntityTest, DefinitionConstructionNameTypeData) {
+  Definition d("foo", FormatEntity::Entry::Type::Invalid, 33);
+
+  EXPECT_EQ(d.name, "foo");
+  EXPECT_EQ(d.string, nullptr);
+  EXPECT_EQ(d.type, FormatEntity::Entry::Type::Invalid);
+  EXPECT_EQ(d.data, 33UL);
+  EXPECT_EQ(d.num_children, 0UL);
+  EXPECT_EQ(d.children, nullptr);
+  EXPECT_FALSE(d.keep_separator);
+}
+
+TEST(FormatEntityTest, DefinitionConstructionNameTypeChildren) {
+  Definition d("foo", FormatEntity::Entry::Type::Invalid, 33);
+  Definition parent("parent", FormatEntity::Entry::Type::Invalid, 1, &d);
+  EXPECT_EQ(parent.name, "parent");
+  EXPECT_EQ(parent.string, nullptr);
+  EXPECT_EQ(parent.type, FormatEntity::Entry::Type::Invalid);
+  EXPECT_EQ(parent.num_children, 1UL);
+  EXPECT_EQ(parent.children, &d);
+  EXPECT_FALSE(parent.keep_separator);
+
+  EXPECT_EQ(parent.children[0].name, "foo");
+  EXPECT_EQ(parent.children[0].string, nullptr);
+  EXPECT_EQ(parent.children[0].type, FormatEntity::Entry::Type::Invalid);
+  EXPECT_EQ(parent.children[0].data, 33UL);
+  EXPECT_EQ(parent.children[0].num_children, 0UL);
+  EXPECT_EQ(parent.children[0].children, nullptr);
+  EXPECT_FALSE(d.keep_separator);
+}
+
+constexpr llvm::StringRef lookupStrings[] = {
+"${addr.load}",
+"${addr.file}",
+"${ansi.fg.black}",
+"${ansi.fg.red}",
+"${ansi.fg.green}",
+"${ansi.fg.yellow}",
+"${ansi.fg.blue}",
+"${ansi.fg.purple}",
+"${ansi.fg.cyan}",
+"${ansi.fg.white}",
+"${ansi.bg.black}",
+"${ansi.bg.red}",
+"${ansi.bg.green}",
+"${ansi.bg.yellow}",
+"${ansi.bg.blue}",
+"${ansi.bg.purple}",
+"${ansi.bg.cyan}",
+"${ansi.bg.white}",
+"${file.basename}",
+"${file.dirname}",
+"${file.fullpath}",
+"${frame.index}",
+"${frame.pc}",
+"${frame.fp}",
+"${frame.sp}",
+"${frame.flags}",
+"${frame.no-debug}",
+"${frame.reg.*}",
+"${frame.is-artificial}",
+"${function.id}",
+"${function.name}",
+"${function.name-without-args}",
+"${function.name-with-args}",
+"${function.mangled-name}",
+"${function.addr-offset}",
+"${function.concrete-only-addr-offset-no-padding}",
+"${function.line-offset}",
+"${function.pc-offset}",
+"${function.initial-function}",
+"${function.changed}",
+"${function.is-optimized}",
+"${line.file.basename}",
+"${line.file.dirname}",
+"${line.file.fullpath}",
+"${line.number}",
+"${line.column}",
+"${line.start-addr}",
+"${line.end-addr}",
+"${module.file.basename}",
+"${module.file.dirname}",
+"${module.file.fullpath}",
+"${process.id}",
+"${process.name}",
+"${process.file.basename}",
+"${process.file.dirname}",
+"${process.file.fullpath}",
+"${script.frame}",
+"${script.process}",
+"${script.target}",
+"${s

[Lldb-commits] [lldb] 73cf85e - [LLDB] Skip TestVSCode_disconnect.test_launch arm/linux

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

Author: Muhammad Omair Javaid
Date: 2021-03-26T15:54:42+05:00
New Revision: 73cf85e527f69c495daece7c74743b9073d4717c

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

LOG: [LLDB] Skip TestVSCode_disconnect.test_launch arm/linux

TestVSCode_disconnect.test_launch hangs in tear down and times out
Arm linux. I am marking it skipped for the buildbot while looking
into failure.

Added: 


Modified: 
lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py

Removed: 




diff  --git 
a/lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py 
b/lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py
index 2de3ed9e1e98..91b2ae783048 100644
--- a/lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py
+++ b/lldb/test/API/tools/lldb-vscode/disconnect/TestVSCode_disconnect.py
@@ -29,6 +29,7 @@ def disconnect_and_assert_no_output_printed(self):
 @skipIfDarwin
 @skipIfWindows
 @skipIfRemote
+@skipIf(oslist=["linux"], archs=["arm"])
 def test_launch(self):
 """
 This test launches a process that would creates a file, but we 
disconnect



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


[Lldb-commits] [lldb] 21589d0 - [lldb] XFAIL TestGdbRemote_vContThreads on macos

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

Author: Pavel Labath
Date: 2021-03-26T17:26:44+01:00
New Revision: 21589d07665cc167e8ce6afa12ac8d9c972f9ce2

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

LOG: [lldb] XFAIL TestGdbRemote_vContThreads on macos

It seems debugserver does not implement these packets.

Added: 


Modified: 
lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
index d33a9699f3b97..fc65e67393764 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemote_vContThreads.py
@@ -51,6 +51,7 @@ def send_and_check_signal(self, vCont_data, threads):
 
 @skipIfWindows
 @expectedFailureNetBSD
+@expectedFailureDarwin # No signals delivered
 def test_signal_process_without_tid(self):
 self.build()
 self.set_inferior_startup_launch()
@@ -74,6 +75,7 @@ def test_signal_one_thread(self):
 
 @skipIfWindows
 @expectedFailureNetBSD
+@expectedFailureDarwin # Only one signal delivered
 def test_signal_all_threads(self):
 self.build()
 self.set_inferior_startup_launch()



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


[Lldb-commits] [lldb] 22e2d11 - [lldb] Really fix dwarf5-debug_line-file-index.s

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

Author: Pavel Labath
Date: 2021-03-26T17:26:44+01:00
New Revision: 22e2d117d3b9f04a66e03698f930c6f9ac538d69

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

LOG: [lldb] Really fix dwarf5-debug_line-file-index.s

It's not enough the change the comment -- one has to actually change the
constant before it. :/

Added: 


Modified: 
lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s 
b/lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s
index 7bddd3bbbd209..54d07df104316 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s
+++ b/lldb/test/Shell/SymbolFile/DWARF/dwarf5-debug_line-file-index.s
@@ -1,7 +1,5 @@
 # Test handling of DWARF5 file index 0.
 # REQUIRES: x86
-# XFAIL: target-arm && linux-gnu
-# XFAIL: system-windows
 
 # RUN: llvm-mc -filetype=obj -o %t -triple x86_64-pc-linux %s
 # RUN: %lldb %t -o "image lookup -f hello.c -l 1" \
@@ -19,7 +17,7 @@
.section.debug_abbrev,"",@progbits
.byte   1   # Abbreviation Code
.byte   17  # DW_TAG_compile_unit
-   .byte   1   # DW_CHILDREN_no
+   .byte   0   # DW_CHILDREN_no
.byte   37  # DW_AT_producer
.byte   37  # DW_FORM_strx1
.byte   19  # DW_AT_language



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


[Lldb-commits] [lldb] 5c3aed9 - [lldb] Skip TestVSCode_launch.test_progress_events on linux

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

Author: Pavel Labath
Date: 2021-03-26T17:26:44+01:00
New Revision: 5c3aed98afda5f3016deaca4671634cee449235b

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

LOG: [lldb] Skip TestVSCode_launch.test_progress_events on linux

It's flaky everywhere, not just arm.

Added: 


Modified: 
lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py 
b/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
index 3cfebb689a5b..aceed56fe249 100644
--- a/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
+++ b/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
@@ -454,7 +454,7 @@ def test_terminate_commands(self):
 
 @skipIfWindows
 @skipIfRemote
-@skipIf(oslist=["linux"], archs=["arm"])
+@skipIf(oslist=["linux"])
 def test_progress_events(self):
 '''
 Tests the progress events to ensure we are receiving them.



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


[Lldb-commits] [PATCH] D97739: Add a progress class that can track and report long running operations that happen in LLDB.

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

This test is flaky (even after the vdso fix by raphael), and it seems like it 
could be a genuine problem: http://lab.llvm.org:8011/#/builders/68/builds/9440, 
http://lab.llvm.org:8011/#/builders/68/builds/9409, 
http://lab.llvm.org:8011/#/builders/68/builds/9403, 
http://lab.llvm.org:8011/#/builders/68/builds/9383, ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97739

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


Re: [Lldb-commits] [PATCH] D97739: Add a progress class that can track and report long running operations that happen in LLDB.

2021-03-26 Thread Greg Clayton via lldb-commits
I will take a look and apply this patch on my linux server and enable ASAN. 
Looks like lldb-vscode must be crashing from what the errors look like.

> On Mar 26, 2021, at 9:29 AM, Pavel Labath via Phabricator 
>  wrote:
> 
> labath added a comment.
> 
> This test is flaky (even after the vdso fix by raphael), and it seems like it 
> could be a genuine problem: 
> http://lab.llvm.org:8011/#/builders/68/builds/9440, 
> http://lab.llvm.org:8011/#/builders/68/builds/9409, 
> http://lab.llvm.org:8011/#/builders/68/builds/9403, 
> http://lab.llvm.org:8011/#/builders/68/builds/9383, ...
> 
> 
> Repository:
>  rG LLVM Github Monorepo
> 
> CHANGES SINCE LAST ACTION
>  https://reviews.llvm.org/D97739/new/
> 
> https://reviews.llvm.org/D97739
> 

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


[Lldb-commits] [PATCH] D99401: Fix .debug_aranges parsing issues introduced with llvm error handling in LLDB

2021-03-26 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added a comment.

(generally makes sense to me - but I'll leave it to some more lldb-focussed 
reviewers to do more review/approval)

Usual caveat/question: Does this take us closer or further away from unifying 
this code with LLVM's libDebugInfoDWARF? (or neutral)




Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp:56
+  if (m_header.length > 0)
+m_next_offset = m_offset + *offset_ptr - m_offset + m_header.length;
+  else

This maths seems strange - the `m_offset ... - m_offset` cancel each other out, 
right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99401

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


[Lldb-commits] [PATCH] D99401: Fix .debug_aranges parsing issues introduced with llvm error handling in LLDB

2021-03-26 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

In D99401#2653285 , @dblaikie wrote:

> (generally makes sense to me - but I'll leave it to some more lldb-focussed 
> reviewers to do more review/approval)
>
> Usual caveat/question: Does this take us closer or further away from unifying 
> this code with LLVM's libDebugInfoDWARF? (or neutral)

It is neutral right now, maintains the current separation.




Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp:56
+  if (m_header.length > 0)
+m_next_offset = m_offset + *offset_ptr - m_offset + m_header.length;
+  else

dblaikie wrote:
> This maths seems strange - the `m_offset ... - m_offset` cancel each other 
> out, right?
Math is good. We are adding the number of bytes that were used to encode the 
length (4 or 12) by saying:
```
m_offset +  + m_header.length
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99401

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


[Lldb-commits] [PATCH] D98886: Pass pointer authentication code mask from minidump and use to strip pac from pc.

2021-03-26 Thread Justin Cohen via Phabricator via lldb-commits
justincohen updated this revision to Diff 333601.
justincohen added a comment.

Inverted mask.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98886

Files:
  lldb/include/lldb/Target/Process.h
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.h
  lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/source/Plugins/Process/minidump/MinidumpParser.h
  lldb/source/Plugins/Process/minidump/MinidumpTypes.h
  lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/TargetProperties.td
  llvm/include/llvm/BinaryFormat/MinidumpConstants.def

Index: llvm/include/llvm/BinaryFormat/MinidumpConstants.def
===
--- llvm/include/llvm/BinaryFormat/MinidumpConstants.def
+++ llvm/include/llvm/BinaryFormat/MinidumpConstants.def
@@ -56,6 +56,8 @@
 HANDLE_MDMP_STREAM_TYPE(0x0014, JavascriptData)
 HANDLE_MDMP_STREAM_TYPE(0x0015, SystemMemoryInfo)
 HANDLE_MDMP_STREAM_TYPE(0x0016, ProcessVMCounters)
+// Crashpad extension types.  0x4350 = "CP"
+HANDLE_MDMP_STREAM_TYPE(0x4351, CrashpadInfo)
 // Breakpad extension types.  0x4767 = "Gg"
 HANDLE_MDMP_STREAM_TYPE(0x47670001, BreakpadInfo)
 HANDLE_MDMP_STREAM_TYPE(0x47670002, AssertionInfo)
Index: lldb/source/Target/TargetProperties.td
===
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -199,6 +199,9 @@
 Global,
 DefaultTrue,
 Desc<"If true, errors in expression evaluation will unwind the stack back to the state before the call.">;
+  def PointerAuthenticationAddressMask: Property<"pointer-authentication-address-mask", "UInt64">,
+DefaultUnsignedValue<0>,
+Desc<"Specifies which bits need to be cleared from the pointer.  To use the mask, AND with the inverse.">;
   def PythonOSPluginPath: Property<"python-os-plugin-path", "FileSpec">,
 DefaultUnsignedValue<1>,
 Desc<"A path to a python OS plug-in module file that contains a OperatingSystemPlugIn class.">;
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -195,6 +195,18 @@
   m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, args);
 }
 
+uint64_t ProcessProperties::GetPointerAuthenticationAddressMask() const {
+  const uint32_t idx = ePropertyPointerAuthenticationAddressMask;
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(
+  nullptr, idx, g_process_properties[idx].default_uint_value);
+}
+
+void ProcessProperties::SetPointerAuthenticationAddressMask(
+const uint64_t mask) {
+  const uint32_t idx = ePropertyPointerAuthenticationAddressMask;
+  m_collection_sp->SetPropertyAtIndexAsUInt64(nullptr, idx, mask);
+}
+
 FileSpec ProcessProperties::GetPythonOSPluginPath() const {
   const uint32_t idx = ePropertyPythonOSPluginPath;
   return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
Index: lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
===
--- lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -302,6 +302,12 @@
   }
   SetID(pid.getValue());
 
+  llvm::Optional mask =
+  m_minidump_parser->GetPointerAuthenticationAddressMask();
+  if (mask) {
+SetPointerAuthenticationAddressMask(mask.getValue());
+  }
+
   return error;
 }
 
Index: lldb/source/Plugins/Process/minidump/MinidumpTypes.h
===
--- lldb/source/Plugins/Process/minidump/MinidumpTypes.h
+++ lldb/source/Plugins/Process/minidump/MinidumpTypes.h
@@ -102,6 +102,24 @@
   LinuxProcStatus() = default;
 };
 
+struct GUID {
+  llvm::support::ulittle32_t data1;
+  llvm::support::ulittle16_t data2;
+  llvm::support::ulittle16_t data3;
+  uint8_t data4[8];
+};
+static_assert(sizeof(GUID) == 16, "");
+
+struct CrashpadInfo {
+  llvm::support::ulittle32_t version;
+  GUID report_id;
+  GUID client_id;
+  LocationDescriptor simple_annotations;
+  LocationDescriptor module_list;
+  llvm::support::ulittle64_t pointer_authentication_address_mask;
+};
+static_assert(sizeof(CrashpadInfo) == 60, "");
+
 } // namespace minidump
 } // namespace lldb_private
 #endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_MINIDUMPTYPES_H
Index: lldb/source/Plugins/Process/minidump/MinidumpParser.h
===
--- lldb/source/Plugins/Process/minidump/MinidumpParser.h
+++ lldb/source/Plugins/Process/minidump/MinidumpParser.h
@@ -71,6 +71,7 @@
   const MinidumpMiscInfo *GetMiscInfo();
 
   llvm::Optional GetLinuxProcStatus();
+  llvm::Optional GetPointerAuthenticationAddressMask();
 
   llvm::Optional 

[Lldb-commits] [PATCH] D99401: Fix .debug_aranges parsing issues introduced with llvm error handling in LLDB

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



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h:19
   struct Header {
-uint32_t length;// The total length of the entries for that set, not
-// including the length field itself.
-uint16_t version;   // The DWARF version number
-uint32_t cu_offset; // The offset from the beginning of the .debug_info
-// section of the compilation unit entry referenced by
-// the table.
-uint8_t addr_size;  // The size in bytes of an address on the target
-// architecture. For segmented addressing, this is the
-// size of the offset portion of the address
-uint8_t seg_size; // The size in bytes of a segment descriptor on the 
target
-  // architecture. If the target system uses a flat address
-  // space, this value is 0.
+uint32_t length = 0;// The total length of the entries for that set,
+// not including the length field itself.

Nit: Can you put these above the members (because of the 80 col limit) and make 
them Doxygen comments (`///`)?



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h:47
   const Header &GetHeader() const { return m_header; }
-
+  lldb::offset_t GetNextOffset() const { return m_next_offset; }
   const Descriptor &GetDescriptorRef(uint32_t i) const {

`dw_offset_t`? 



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp:63-67
+// with the current DWARFDebugArangeSet. Previously if there was an error,
+// like finding two zero terminator addresses early, the previous
+// DWARFDebugArangeSet would stop parsing the DWARFDebugArangeSet data and
+// then the next DWARFDebugArangeSet would end up parsing left over
+// addresses as a new DWARFDebugArangeSet header and it would error out.

Nit: I would phrase this as an example rather than in terms of what the old 
code did.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99401

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


[Lldb-commits] [PATCH] D99315: [lldb] Support lazily named classes in the Objective-C classes

2021-03-26 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

> I'm planning on moving the corresponding 3 instance variables for the shared 
> cache into a SharedCacheClassInfoExtractor in a follow up patch.

LGTM as an intermediate step.


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

https://reviews.llvm.org/D99315

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


[Lldb-commits] [PATCH] D98886: Pass pointer authentication code mask from minidump and use to strip pac from pc.

2021-03-26 Thread Justin Cohen via Phabricator via lldb-commits
justincohen updated this revision to Diff 333608.
justincohen added a comment.

Check CrashpadInfo version.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98886

Files:
  lldb/include/lldb/Target/Process.h
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.h
  lldb/source/Plugins/Process/minidump/MinidumpParser.cpp
  lldb/source/Plugins/Process/minidump/MinidumpParser.h
  lldb/source/Plugins/Process/minidump/MinidumpTypes.h
  lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/TargetProperties.td
  llvm/include/llvm/BinaryFormat/MinidumpConstants.def

Index: llvm/include/llvm/BinaryFormat/MinidumpConstants.def
===
--- llvm/include/llvm/BinaryFormat/MinidumpConstants.def
+++ llvm/include/llvm/BinaryFormat/MinidumpConstants.def
@@ -56,6 +56,8 @@
 HANDLE_MDMP_STREAM_TYPE(0x0014, JavascriptData)
 HANDLE_MDMP_STREAM_TYPE(0x0015, SystemMemoryInfo)
 HANDLE_MDMP_STREAM_TYPE(0x0016, ProcessVMCounters)
+// Crashpad extension types.  0x4350 = "CP"
+HANDLE_MDMP_STREAM_TYPE(0x4351, CrashpadInfo)
 // Breakpad extension types.  0x4767 = "Gg"
 HANDLE_MDMP_STREAM_TYPE(0x47670001, BreakpadInfo)
 HANDLE_MDMP_STREAM_TYPE(0x47670002, AssertionInfo)
Index: lldb/source/Target/TargetProperties.td
===
--- lldb/source/Target/TargetProperties.td
+++ lldb/source/Target/TargetProperties.td
@@ -199,6 +199,9 @@
 Global,
 DefaultTrue,
 Desc<"If true, errors in expression evaluation will unwind the stack back to the state before the call.">;
+  def PointerAuthenticationAddressMask: Property<"pointer-authentication-address-mask", "UInt64">,
+DefaultUnsignedValue<0>,
+Desc<"Specifies which bits need to be cleared from the pointer.  To use the mask, AND with the inverse.">;
   def PythonOSPluginPath: Property<"python-os-plugin-path", "FileSpec">,
 DefaultUnsignedValue<1>,
 Desc<"A path to a python OS plug-in module file that contains a OperatingSystemPlugIn class.">;
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -195,6 +195,18 @@
   m_collection_sp->SetPropertyAtIndexFromArgs(nullptr, idx, args);
 }
 
+uint64_t ProcessProperties::GetPointerAuthenticationAddressMask() const {
+  const uint32_t idx = ePropertyPointerAuthenticationAddressMask;
+  return m_collection_sp->GetPropertyAtIndexAsUInt64(
+  nullptr, idx, g_process_properties[idx].default_uint_value);
+}
+
+void ProcessProperties::SetPointerAuthenticationAddressMask(
+const uint64_t mask) {
+  const uint32_t idx = ePropertyPointerAuthenticationAddressMask;
+  m_collection_sp->SetPropertyAtIndexAsUInt64(nullptr, idx, mask);
+}
+
 FileSpec ProcessProperties::GetPythonOSPluginPath() const {
   const uint32_t idx = ePropertyPythonOSPluginPath;
   return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx);
Index: lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
===
--- lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
+++ lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
@@ -302,6 +302,12 @@
   }
   SetID(pid.getValue());
 
+  llvm::Optional mask =
+  m_minidump_parser->GetPointerAuthenticationAddressMask();
+  if (mask) {
+SetPointerAuthenticationAddressMask(mask.getValue());
+  }
+
   return error;
 }
 
Index: lldb/source/Plugins/Process/minidump/MinidumpTypes.h
===
--- lldb/source/Plugins/Process/minidump/MinidumpTypes.h
+++ lldb/source/Plugins/Process/minidump/MinidumpTypes.h
@@ -102,6 +102,24 @@
   LinuxProcStatus() = default;
 };
 
+struct GUID {
+  llvm::support::ulittle32_t data1;
+  llvm::support::ulittle16_t data2;
+  llvm::support::ulittle16_t data3;
+  uint8_t data4[8];
+};
+static_assert(sizeof(GUID) == 16, "");
+
+struct CrashpadInfo {
+  llvm::support::ulittle32_t version;
+  GUID report_id;
+  GUID client_id;
+  LocationDescriptor simple_annotations;
+  LocationDescriptor module_list;
+  llvm::support::ulittle64_t pointer_authentication_address_mask;
+};
+static_assert(sizeof(CrashpadInfo) == 60, "");
+
 } // namespace minidump
 } // namespace lldb_private
 #endif // LLDB_SOURCE_PLUGINS_PROCESS_MINIDUMP_MINIDUMPTYPES_H
Index: lldb/source/Plugins/Process/minidump/MinidumpParser.h
===
--- lldb/source/Plugins/Process/minidump/MinidumpParser.h
+++ lldb/source/Plugins/Process/minidump/MinidumpParser.h
@@ -71,6 +71,7 @@
   const MinidumpMiscInfo *GetMiscInfo();
 
   llvm::Optional GetLinuxProcStatus();
+  llvm::Optional GetPointerAuthenticationAddressMask();
 
   ll

[Lldb-commits] [PATCH] D98886: Pass pointer authentication code mask from minidump and use to strip pac from pc.

2021-03-26 Thread Justin Cohen via Phabricator via lldb-commits
justincohen marked 2 inline comments as done.
justincohen added inline comments.



Comment at: lldb/source/Plugins/Process/minidump/MinidumpTypes.h:113
+
+struct CrashpadInfo {
+  llvm::support::ulittle32_t version;

markmentovai wrote:
> Ensure alignment is compatible with what Crashpad uses.
Confirmed manually.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98886

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


[Lldb-commits] [lldb] 077aa10 - [lldb] Support lazily named classes in the Objective-C classes

2021-03-26 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-03-26T13:34:08-07:00
New Revision: 077aa102534ac4dee2856da8b8155fbfdcb429af

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

LOG: [lldb] Support lazily named classes in the Objective-C classes

Generic classes in Swift have their name instantiated on request, since
the vast majority never need it, and it just wastes time and memory.
This results in LLDB being unable to determine the dynamic type of these
Swift objects.

The main issues is that lazily named classes are not added to the
gdb_objc_realized_classes hashtable. This means the class count in the
table doesn't change when a class is realized and LLDB doesn't know it
needs to re-parse the class info. But even if it did, the classes are
not in the hash table.

The first change in this patch is that we read
objc_debug_realized_class_generation_count and re-parse the class info
when the count changes.

The second change in this patch is that we use
objc_copyRealizedClassList (if available) to get all realized classes
from the runtime.

Unfortunately, objc_copyRealizedClassList calls _dyld_objc_class_count
in its implementation. As we know, the Objective-C parsing code might
get called before dyld is fully initialized, resulting in crashes or
even a stranded lock. Therefore we only use objc_copyRealizedClassList
when we know it's safe to do so by checking libSystemInitialized in
dyld_all_image_infos.

As a result, it's possible that the first time we read the Objective-C
runtime we are forced to use gdb_objc_realized_classes. This should be
fine, as there should be no lazily named classes at this point.
Subsequent queries will detect the change in realized class generation
count and use objc_copyRealizedClassList.

This patch keeps the old behavior when objc_copyRealizedClassList or
objc_debug_realized_class_generation_count are not available.

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

Added: 


Modified: 

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

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

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 30e094bd3649d..3699310579f3f 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -39,6 +39,7 @@
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Symbol/VariableList.h"
 #include "lldb/Target/ABI.h"
+#include "lldb/Target/DynamicLoader.h"
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
@@ -163,6 +164,72 @@ __lldb_apple_objc_v2_get_dynamic_class_info (void 
*gdb_objc_realized_classes_ptr
 
 )";
 
+static const char *g_get_dynamic_class_info2_name =
+"__lldb_apple_objc_v2_get_dynamic_class_info2";
+
+static const char *g_get_dynamic_class_info2_body = R"(
+
+extern "C" {
+int printf(const char * format, ...);
+void free(void *ptr);
+Class* objc_copyRealizedClassList(unsigned int *outCount);
+const char* objc_debug_class_getNameRaw(Class cls);
+}
+
+#define DEBUG_PRINTF(fmt, ...) if (should_log) printf(fmt, ## __VA_ARGS__)
+
+struct ClassInfo
+{
+Class isa;
+uint32_t hash;
+} __attribute__((__packed__));
+
+uint32_t
+__lldb_apple_objc_v2_get_dynamic_class_info2(void 
*gdb_objc_realized_classes_ptr,
+ void *class_infos_ptr,
+ uint32_t class_infos_byte_size,
+ uint32_t should_log)
+{
+DEBUG_PRINTF ("class_infos_ptr = %p\n", class_infos_ptr);
+DEBUG_PRINTF ("class_infos_byte_size = %u\n", class_infos_byte_size);
+
+const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
+DEBUG_PRINTF ("max_class_infos = %u\n", max_class_infos);
+
+ClassInfo *class_infos = (ClassInfo *)class_infos_ptr;
+
+uint32_t count = 0;
+Class* realized_class_list = objc_copyRealizedClassList(&count);
+
+uint32_t idx = 0;
+for (uint32_t i=0; i<=count; ++i)
+{
+if (idx < max_class_infos)
+{
+Class isa = realized_class_list[i];
+const char *name_ptr = objc_debug_class_getNameRaw(isa);
+const char *s = name_ptr;
+uint32_t h = 5381;
+for (unsigned char c = *s; c; c = *++s)
+h = ((h << 5) + h) + c;
+class_infos[idx].hash = h;
+class_infos[idx].isa = isa;
+DEBUG_PRINTF ("[%u] isa = %8p %s\n", idx, class_infos[idx].isa, 

[Lldb-commits] [PATCH] D99315: [lldb] Support lazily named classes in the Objective-C classes

2021-03-26 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 rG077aa102534a: [lldb] Support lazily named classes in the 
Objective-C classes (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99315

Files:
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h

Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
@@ -293,6 +293,50 @@
 }
   };
 
+  /// We can read the class info from the Objective-C runtime using
+  /// gdb_objc_realized_classes or objc_copyRealizedClassList. The latter is
+  /// preferred because it includes lazily named classes, but it's not always
+  /// available or safe to call.
+  ///
+  /// We potentially need both for the same process,
+  /// because we may need to use gdb_objc_realized_classes until dyld is
+  /// initialized and then switch over to objc_copyRealizedClassList for lazily
+  /// named classes.
+  class DynamicClassInfoExtractor {
+  public:
+DynamicClassInfoExtractor(AppleObjCRuntimeV2 &runtime)
+: m_runtime(runtime) {}
+
+enum Helper { gdb_objc_realized_classes, objc_copyRealizedClassList };
+
+/// Compute which helper to use. Prefer objc_copyRealizedClassList if it's
+/// available and it's safe to call (i.e. dyld is fully initialized). Use
+/// gdb_objc_realized_classes otherwise.
+Helper ComputeHelper() const;
+
+UtilityFunction *GetClassInfoUtilityFunction(ExecutionContext &exe_ctx,
+ Helper helper);
+lldb::addr_t &GetClassInfoArgs(Helper helper);
+std::mutex &GetMutex() { return m_mutex; }
+
+  private:
+std::unique_ptr
+GetClassInfoUtilityFunctionImpl(ExecutionContext &exe_ctx, std::string code,
+std::string name);
+
+/// The lifetime of this object is tied to that of the runtime.
+AppleObjCRuntimeV2 &m_runtime;
+std::mutex m_mutex;
+
+/// Utility function to read class info using gdb_objc_realized_classes.
+std::unique_ptr m_get_class_info_code;
+lldb::addr_t m_get_class_info_args = LLDB_INVALID_ADDRESS;
+
+/// Utility function to read class info using objc_copyRealizedClassList.
+std::unique_ptr m_get_class_info2_code;
+lldb::addr_t m_get_class_info2_args = LLDB_INVALID_ADDRESS;
+  };
+
   AppleObjCRuntimeV2(Process *process, const lldb::ModuleSP &objc_module_sp);
 
   ObjCISA GetPointerISA(ObjCISA isa);
@@ -301,6 +345,12 @@
 
   bool UpdateISAToDescriptorMapFromMemory(RemoteNXMapTable &hash_table);
 
+  /// Update the generation count of realized classes. This is not an exact
+  /// count but rather a value that is incremented when new classes are realized
+  /// or destroyed. Unlike the count in gdb_objc_realized_classes, it will
+  /// change when lazily named classes get realized.
+  bool RealizedClassGenerationCountChanged();
+
   DescriptorMapUpdateResult
   UpdateISAToDescriptorMapDynamic(RemoteNXMapTable &hash_table);
 
@@ -320,6 +370,8 @@
 
   bool GetCFBooleanValuesIfNeeded();
 
+  bool HasSymbol(ConstString Name);
+
   NonPointerISACache *GetNonPointerIsaCache() {
 if (!m_non_pointer_isa_cache_up)
   m_non_pointer_isa_cache_up.reset(
@@ -331,9 +383,7 @@
 
   lldb::ModuleSP m_objc_module_sp;
 
-  std::unique_ptr m_get_class_info_code;
-  lldb::addr_t m_get_class_info_args;
-  std::mutex m_get_class_info_args_mutex;
+  DynamicClassInfoExtractor m_class_info_extractor;
 
   std::unique_ptr m_get_shared_cache_class_info_code;
   lldb::addr_t m_get_shared_cache_class_info_args;
@@ -344,12 +394,14 @@
   lldb::addr_t m_isa_hash_table_ptr;
   HashTableSignature m_hash_signature;
   bool m_has_object_getClass;
+  bool m_has_objc_copyRealizedClassList;
   bool m_loaded_objc_opt;
   std::unique_ptr m_non_pointer_isa_cache_up;
   std::unique_ptr m_tagged_pointer_vendor_up;
   EncodingToTypeSP m_encoding_to_type_sp;
   bool m_noclasses_warning_emitted;
   llvm::Optional> m_CFBoolean_values;
+  uint64_t m_realized_class_generation_count;
 };
 
 } // namespace lldb_private
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -39,6 +39,7 @@
 #include "lldb/Symbol/TypeList.h"
 #include "lldb/Symbol/VariableList.h"
 #includ

[Lldb-commits] [PATCH] D99446: [lldb] Add consistency between reading the dynamic and shared cache class info

2021-03-26 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: aprantl.
JDevlieghere requested review of this revision.

This adds the consistency I promised in D99315 
 between how we read the
class info from the Objective-C runtime and the shared cache. (NFC)


https://reviews.llvm.org/D99446

Files:
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h

Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
@@ -328,13 +328,41 @@
 AppleObjCRuntimeV2 &m_runtime;
 std::mutex m_mutex;
 
-/// Utility function to read class info using gdb_objc_realized_classes.
-std::unique_ptr m_get_class_info_code;
-lldb::addr_t m_get_class_info_args = LLDB_INVALID_ADDRESS;
+/// Helper to read class info using the gdb_objc_realized_classes.
+struct gdb_objc_realized_classes_helper {
+  std::unique_ptr utility_function;
+  lldb::addr_t args = LLDB_INVALID_ADDRESS;
+};
+
+/// Helper to read class info using objc_copyRealizedClassList.
+struct objc_copyRealizedClassList_helper {
+  std::unique_ptr utility_function;
+  lldb::addr_t args = LLDB_INVALID_ADDRESS;
+};
+
+gdb_objc_realized_classes_helper m_gdb_objc_realized_classes_helper;
+objc_copyRealizedClassList_helper m_objc_copyRealizedClassList_helper;
+  };
+
+  class SharedCacheClassInfoExtractor {
+  public:
+SharedCacheClassInfoExtractor(AppleObjCRuntimeV2 &runtime)
+: m_runtime(runtime) {}
+
+UtilityFunction *GetClassInfoUtilityFunction(ExecutionContext &exe_ctx);
+lldb::addr_t &GetClassInfoArgs() { return m_args; }
+std::mutex &GetMutex() { return m_mutex; }
+
+  private:
+std::unique_ptr
+GetClassInfoUtilityFunctionImpl(ExecutionContext &exe_ctx);
 
-/// Utility function to read class info using objc_copyRealizedClassList.
-std::unique_ptr m_get_class_info2_code;
-lldb::addr_t m_get_class_info2_args = LLDB_INVALID_ADDRESS;
+/// The lifetime of this object is tied to that of the runtime.
+AppleObjCRuntimeV2 &m_runtime;
+
+std::unique_ptr m_utility_function;
+lldb::addr_t m_args = LLDB_INVALID_ADDRESS;
+std::mutex m_mutex;
   };
 
   AppleObjCRuntimeV2(Process *process, const lldb::ModuleSP &objc_module_sp);
@@ -383,11 +411,8 @@
 
   lldb::ModuleSP m_objc_module_sp;
 
-  DynamicClassInfoExtractor m_class_info_extractor;
-
-  std::unique_ptr m_get_shared_cache_class_info_code;
-  lldb::addr_t m_get_shared_cache_class_info_args;
-  std::mutex m_get_shared_cache_class_info_args_mutex;
+  DynamicClassInfoExtractor m_dynamic_class_info_extractor;
+  SharedCacheClassInfoExtractor m_shared_cache_class_info_extractor;
 
   std::unique_ptr m_decl_vendor_up;
   lldb::addr_t m_tagged_pointer_obfuscator;
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -482,9 +482,8 @@
 AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process,
const ModuleSP &objc_module_sp)
 : AppleObjCRuntime(process), m_objc_module_sp(objc_module_sp),
-  m_class_info_extractor(*this), m_get_shared_cache_class_info_code(),
-  m_get_shared_cache_class_info_args(LLDB_INVALID_ADDRESS),
-  m_get_shared_cache_class_info_args_mutex(), m_decl_vendor_up(),
+  m_dynamic_class_info_extractor(*this),
+  m_shared_cache_class_info_extractor(*this), m_decl_vendor_up(),
   m_tagged_pointer_obfuscator(LLDB_INVALID_ADDRESS),
   m_isa_hash_table_ptr(LLDB_INVALID_ADDRESS), m_hash_signature(),
   m_has_object_getClass(false), m_has_objc_copyRealizedClassList(false),
@@ -1419,18 +1418,20 @@
 ExecutionContext &exe_ctx, Helper helper) {
   switch (helper) {
   case gdb_objc_realized_classes: {
-if (!m_get_class_info_code)
-  m_get_class_info_code = GetClassInfoUtilityFunctionImpl(
-  exe_ctx, g_get_dynamic_class_info_body,
-  g_get_dynamic_class_info_name);
-return m_get_class_info_code.get();
+if (!m_gdb_objc_realized_classes_helper.utility_function)
+  m_gdb_objc_realized_classes_helper.utility_function =
+  GetClassInfoUtilityFunctionImpl(exe_ctx,
+  g_get_dynamic_class_info_body,
+  g_get_dynamic_class_info_name);
+return m_gdb_objc_realized_classes_helper.utility_function.get();
   }
   case objc_copyRealizedClassList:

[Lldb-commits] [PATCH] D99446: [lldb] Add consistency between reading the dynamic and shared cache class info

2021-03-26 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl accepted this revision.
aprantl added inline comments.
This revision is now accepted and ready to land.



Comment at: 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h:347
+
+  class SharedCacheClassInfoExtractor {
+  public:

Doxygen comment?



Comment at: 
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h:349
+  public:
+SharedCacheClassInfoExtractor(AppleObjCRuntimeV2 &runtime)
+: m_runtime(runtime) {}

Should this implement a shared interface with DynamicClassInfoExtractor or am I 
just being obnoxious?


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

https://reviews.llvm.org/D99446

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


Re: [Lldb-commits] [PATCH] D97739: Add a progress class that can track and report long running operations that happen in LLDB.

2021-03-26 Thread Greg Clayton via lldb-commits
I built on mac with ASAN and ran the tests and they passed just fine. I was 
also able to compile on Debian linux and the tests ran ok for me. Can anyone 
else reproduce this failure?

> On Mar 26, 2021, at 9:29 AM, Pavel Labath via Phabricator 
>  wrote:
> 
> labath added a comment.
> 
> This test is flaky (even after the vdso fix by raphael), and it seems like it 
> could be a genuine problem: 
> http://lab.llvm.org:8011/#/builders/68/builds/9440, 
> http://lab.llvm.org:8011/#/builders/68/builds/9409, 
> http://lab.llvm.org:8011/#/builders/68/builds/9403, 
> http://lab.llvm.org:8011/#/builders/68/builds/9383, ...
> 
> 
> Repository:
>  rG LLVM Github Monorepo
> 
> CHANGES SINCE LAST ACTION
>  https://reviews.llvm.org/D97739/new/
> 
> https://reviews.llvm.org/D97739
> 

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


[Lldb-commits] [PATCH] D99401: Fix .debug_aranges parsing issues introduced with llvm error handling in LLDB

2021-03-26 Thread Greg Clayton via Phabricator via lldb-commits
clayborg updated this revision to Diff 333639.
clayborg added a comment.

Fix issues found by JDevlieghere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99401

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp

Index: lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
===
--- lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
+++ lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
@@ -347,12 +347,101 @@
   EXPECT_EQ(off, 12U); // Parser should read no further than the segment size
 }
 
+TEST_F(SymbolFileDWARFTests, ParseArangesWithMultipleTerminators) {
+  // This .debug_aranges set has multiple terminator entries which appear in
+  // binaries produced by popular linux compilers and linker combinations. We
+  // must be able to parse all the way through the data for each
+  // DWARFDebugArangeSet. Previously the DWARFDebugArangeSet::extract()
+  // function would stop parsing as soon as we ran into a terminator even
+  // though the length field stated that there was more data that follows. This
+  // would cause the next DWARFDebugArangeSet to be parsed immediately
+  // following the first terminator and it would attempt to decode the
+  // DWARFDebugArangeSet header using the remaining segment + address pairs
+  // from the remaining bytes.
+  unsigned char binary_data[] = {
+  0, 0, 0, 0, // unit_length that will be set correctly after this
+  0, 2,   // DWARF version number (uint16_t)
+  0, 0, 0, 0, // CU offset (ignored for the purposes of this test)
+  4,  // address size
+  0,  // segment size
+  0, 0, 0, 0, // alignment for the first tuple
+  // BEGIN TUPLES
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // premature terminator
+  0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, // [0x1000-0x1100)
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // premature terminator
+  0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10, // [0x2000-0x2010)
+  // END TUPLES
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // terminator
+  };
+  // Set the big endian length correctly.
+  const offset_t binary_data_size = sizeof(binary_data);
+  binary_data[3] = (uint8_t)binary_data_size - 4;
+  DWARFDataExtractor data;
+  data.SetData(static_cast(binary_data), sizeof binary_data,
+   lldb::ByteOrder::eByteOrderBig);
+  DWARFDebugArangeSet set;
+  offset_t off = 0;
+  llvm::Error error = set.extract(data, &off);
+  // Multiple terminators are not fatal as they do appear in binaries.
+  EXPECT_FALSE(bool(error));
+  // Parser should read all terminators to the end of the length specified.
+  EXPECT_EQ(off, binary_data_size);
+  ASSERT_EQ(set.NumDescriptors(), 2U);
+  ASSERT_EQ(set.GetDescriptorRef(0).address, (dw_addr_t)0x1000);
+  ASSERT_EQ(set.GetDescriptorRef(0).length, (dw_addr_t)0x100);
+  ASSERT_EQ(set.GetDescriptorRef(1).address, (dw_addr_t)0x2000);
+  ASSERT_EQ(set.GetDescriptorRef(1).length, (dw_addr_t)0x10);
+}
+
+TEST_F(SymbolFileDWARFTests, ParseArangesIgnoreEmpty) {
+  // This .debug_aranges set has some address ranges which have zero length
+  // and we ensure that these are ignored by our DWARFDebugArangeSet parser
+  // and not included in the descriptors that are returned.
+  unsigned char binary_data[] = {
+  0, 0, 0, 0, // unit_length that will be set correctly after this
+  0, 2,   // DWARF version number (uint16_t)
+  0, 0, 0, 0, // CU offset (ignored for the purposes of this test)
+  4,  // address size
+  0,  // segment size
+  0, 0, 0, 0, // alignment for the first tuple
+  // BEGIN TUPLES
+  0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, // [0x1000-0x1100)
+  0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, // [0x1100-0x1100)
+  0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10, // [0x2000-0x2010)
+  0x00, 0x00, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, // [0x2010-0x2010)
+  // END TUPLES
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // terminator
+  };
+  // Set the big endian length correctly.
+  const offset_t binary_data_size = sizeof(binary_data);
+  binary_data[3] = (uint8_t)binary_data_size - 4;
+  DWARFDataExtractor data;
+  data.SetData(static_cast(binary_data), sizeof binary_data,
+   lldb::ByteOrder::eByteOrderBig);
+  DWARFDebugArangeSet set;
+  offset_t off = 0;
+  llvm::Error error = set.extract(data, &off);
+  // Multiple

[Lldb-commits] [PATCH] D99401: Fix .debug_aranges parsing issues introduced with llvm error handling in LLDB

2021-03-26 Thread David Blaikie via Phabricator via lldb-commits
dblaikie added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp:56
+  if (m_header.length > 0)
+m_next_offset = m_offset + *offset_ptr - m_offset + m_header.length;
+  else

clayborg wrote:
> dblaikie wrote:
> > This maths seems strange - the `m_offset ... - m_offset` cancel each other 
> > out, right?
> Math is good. We are adding the number of bytes that were used to encode the 
> length (4 or 12) by saying:
> ```
> m_offset +  + m_header.length
> ```
The net effect ends up a bit convoluted & I think it'd be (at least I'd find 
it) easier to read as `*offset_ptr + m_header.length`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99401

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


[Lldb-commits] [PATCH] D99401: Fix .debug_aranges parsing issues introduced with llvm error handling in LLDB

2021-03-26 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp:56
+  if (m_header.length > 0)
+m_next_offset = m_offset + *offset_ptr - m_offset + m_header.length;
+  else

Ah yes! I will change it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99401

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


[Lldb-commits] [PATCH] D99401: Fix .debug_aranges parsing issues introduced with llvm error handling in LLDB

2021-03-26 Thread Greg Clayton via Phabricator via lldb-commits
clayborg updated this revision to Diff 333640.
clayborg added a comment.

Simplify expression for calculating the m_next_offset.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99401

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp

Index: lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
===
--- lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
+++ lldb/unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp
@@ -347,12 +347,101 @@
   EXPECT_EQ(off, 12U); // Parser should read no further than the segment size
 }
 
+TEST_F(SymbolFileDWARFTests, ParseArangesWithMultipleTerminators) {
+  // This .debug_aranges set has multiple terminator entries which appear in
+  // binaries produced by popular linux compilers and linker combinations. We
+  // must be able to parse all the way through the data for each
+  // DWARFDebugArangeSet. Previously the DWARFDebugArangeSet::extract()
+  // function would stop parsing as soon as we ran into a terminator even
+  // though the length field stated that there was more data that follows. This
+  // would cause the next DWARFDebugArangeSet to be parsed immediately
+  // following the first terminator and it would attempt to decode the
+  // DWARFDebugArangeSet header using the remaining segment + address pairs
+  // from the remaining bytes.
+  unsigned char binary_data[] = {
+  0, 0, 0, 0, // unit_length that will be set correctly after this
+  0, 2,   // DWARF version number (uint16_t)
+  0, 0, 0, 0, // CU offset (ignored for the purposes of this test)
+  4,  // address size
+  0,  // segment size
+  0, 0, 0, 0, // alignment for the first tuple
+  // BEGIN TUPLES
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // premature terminator
+  0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, // [0x1000-0x1100)
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // premature terminator
+  0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10, // [0x2000-0x2010)
+  // END TUPLES
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // terminator
+  };
+  // Set the big endian length correctly.
+  const offset_t binary_data_size = sizeof(binary_data);
+  binary_data[3] = (uint8_t)binary_data_size - 4;
+  DWARFDataExtractor data;
+  data.SetData(static_cast(binary_data), sizeof binary_data,
+   lldb::ByteOrder::eByteOrderBig);
+  DWARFDebugArangeSet set;
+  offset_t off = 0;
+  llvm::Error error = set.extract(data, &off);
+  // Multiple terminators are not fatal as they do appear in binaries.
+  EXPECT_FALSE(bool(error));
+  // Parser should read all terminators to the end of the length specified.
+  EXPECT_EQ(off, binary_data_size);
+  ASSERT_EQ(set.NumDescriptors(), 2U);
+  ASSERT_EQ(set.GetDescriptorRef(0).address, (dw_addr_t)0x1000);
+  ASSERT_EQ(set.GetDescriptorRef(0).length, (dw_addr_t)0x100);
+  ASSERT_EQ(set.GetDescriptorRef(1).address, (dw_addr_t)0x2000);
+  ASSERT_EQ(set.GetDescriptorRef(1).length, (dw_addr_t)0x10);
+}
+
+TEST_F(SymbolFileDWARFTests, ParseArangesIgnoreEmpty) {
+  // This .debug_aranges set has some address ranges which have zero length
+  // and we ensure that these are ignored by our DWARFDebugArangeSet parser
+  // and not included in the descriptors that are returned.
+  unsigned char binary_data[] = {
+  0, 0, 0, 0, // unit_length that will be set correctly after this
+  0, 2,   // DWARF version number (uint16_t)
+  0, 0, 0, 0, // CU offset (ignored for the purposes of this test)
+  4,  // address size
+  0,  // segment size
+  0, 0, 0, 0, // alignment for the first tuple
+  // BEGIN TUPLES
+  0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, // [0x1000-0x1100)
+  0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, // [0x1100-0x1100)
+  0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10, // [0x2000-0x2010)
+  0x00, 0x00, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, // [0x2010-0x2010)
+  // END TUPLES
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // terminator
+  };
+  // Set the big endian length correctly.
+  const offset_t binary_data_size = sizeof(binary_data);
+  binary_data[3] = (uint8_t)binary_data_size - 4;
+  DWARFDataExtractor data;
+  data.SetData(static_cast(binary_data), sizeof binary_data,
+   lldb::ByteOrder::eByteOrderBig);
+  DWARFDebugArangeSet set;
+  offset_t off = 0;
+  llvm::Error error = set.extract(data, 

[Lldb-commits] [lldb] 645764f - [lldb] Add consistency between reading the dynamic and shared cache class info

2021-03-26 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-03-26T15:19:21-07:00
New Revision: 645764f3aae83468ca6f9fbd403ab8cf03c91b5a

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

LOG: [lldb] Add consistency between reading the dynamic and shared cache class 
info

This adds the consistency I promised in D99315 between how we read the
class info from the Objective-C runtime and the shared cache. (NFC)

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

Added: 


Modified: 

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

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

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 3699310579f3..225f1af090ea 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -482,9 +482,8 @@ static void RegisterObjCExceptionRecognizer(Process 
*process);
 AppleObjCRuntimeV2::AppleObjCRuntimeV2(Process *process,
const ModuleSP &objc_module_sp)
 : AppleObjCRuntime(process), m_objc_module_sp(objc_module_sp),
-  m_class_info_extractor(*this), m_get_shared_cache_class_info_code(),
-  m_get_shared_cache_class_info_args(LLDB_INVALID_ADDRESS),
-  m_get_shared_cache_class_info_args_mutex(), m_decl_vendor_up(),
+  m_dynamic_class_info_extractor(*this),
+  m_shared_cache_class_info_extractor(*this), m_decl_vendor_up(),
   m_tagged_pointer_obfuscator(LLDB_INVALID_ADDRESS),
   m_isa_hash_table_ptr(LLDB_INVALID_ADDRESS), m_hash_signature(),
   m_has_object_getClass(false), m_has_objc_copyRealizedClassList(false),
@@ -1419,18 +1418,20 @@ 
AppleObjCRuntimeV2::DynamicClassInfoExtractor::GetClassInfoUtilityFunction(
 ExecutionContext &exe_ctx, Helper helper) {
   switch (helper) {
   case gdb_objc_realized_classes: {
-if (!m_get_class_info_code)
-  m_get_class_info_code = GetClassInfoUtilityFunctionImpl(
-  exe_ctx, g_get_dynamic_class_info_body,
-  g_get_dynamic_class_info_name);
-return m_get_class_info_code.get();
+if (!m_gdb_objc_realized_classes_helper.utility_function)
+  m_gdb_objc_realized_classes_helper.utility_function =
+  GetClassInfoUtilityFunctionImpl(exe_ctx,
+  g_get_dynamic_class_info_body,
+  g_get_dynamic_class_info_name);
+return m_gdb_objc_realized_classes_helper.utility_function.get();
   }
   case objc_copyRealizedClassList: {
-if (!m_get_class_info2_code)
-  m_get_class_info2_code = GetClassInfoUtilityFunctionImpl(
-  exe_ctx, g_get_dynamic_class_info2_body,
-  g_get_dynamic_class_info2_name);
-return m_get_class_info2_code.get();
+if (!m_objc_copyRealizedClassList_helper.utility_function)
+  m_objc_copyRealizedClassList_helper.utility_function =
+  GetClassInfoUtilityFunctionImpl(exe_ctx,
+  g_get_dynamic_class_info2_body,
+  g_get_dynamic_class_info2_name);
+return m_objc_copyRealizedClassList_helper.utility_function.get();
   }
   };
 }
@@ -1439,9 +1440,9 @@ lldb::addr_t &
 AppleObjCRuntimeV2::DynamicClassInfoExtractor::GetClassInfoArgs(Helper helper) 
{
   switch (helper) {
   case gdb_objc_realized_classes:
-return m_get_class_info_args;
+return m_gdb_objc_realized_classes_helper.args;
   case objc_copyRealizedClassList:
-return m_get_class_info2_args;
+return m_objc_copyRealizedClassList_helper.args;
   }
 }
 
@@ -1460,6 +1461,95 @@ 
AppleObjCRuntimeV2::DynamicClassInfoExtractor::ComputeHelper() const {
   return DynamicClassInfoExtractor::gdb_objc_realized_classes;
 }
 
+std::unique_ptr
+AppleObjCRuntimeV2::SharedCacheClassInfoExtractor::
+GetClassInfoUtilityFunctionImpl(ExecutionContext &exe_ctx) {
+  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_TYPES));
+
+  LLDB_LOG(log, "Creating utility function {0}",
+   g_get_shared_cache_class_info_name);
+
+  TypeSystemClang *ast =
+  ScratchTypeSystemClang::GetForTarget(exe_ctx.GetTargetRef());
+  if (!ast)
+return {};
+
+  // If the inferior objc.dylib has the class_getNameRaw function, use that in
+  // our jitted expression.  Else fall back to the old class_getName.
+  static ConstString g_class_getName_symbol_name("class_getName");
+  static ConstString g_class_getNameRaw_symbol_name(
+  "objc_debug_class_getNameRaw");
+
+  ConstString class_name_getter_function_name =
+

[Lldb-commits] [PATCH] D99446: [lldb] Add consistency between reading the dynamic and shared cache class info

2021-03-26 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.
JDevlieghere marked 2 inline comments as done.
Closed by commit rG645764f3aae8: [lldb] Add consistency between reading the 
dynamic and shared cache class info (authored by JDevlieghere).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D99446?vs=333638&id=333644#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99446

Files:
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h

Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
@@ -293,19 +293,30 @@
 }
   };
 
+  /// Abstraction to read the Objective-C class info.
+  class ClassInfoExtractor {
+  public:
+ClassInfoExtractor(AppleObjCRuntimeV2 &runtime) : m_runtime(runtime) {}
+std::mutex &GetMutex() { return m_mutex; }
+
+  protected:
+/// The lifetime of this object is tied to that of the runtime.
+AppleObjCRuntimeV2 &m_runtime;
+std::mutex m_mutex;
+  };
+
   /// We can read the class info from the Objective-C runtime using
   /// gdb_objc_realized_classes or objc_copyRealizedClassList. The latter is
   /// preferred because it includes lazily named classes, but it's not always
   /// available or safe to call.
   ///
-  /// We potentially need both for the same process,
-  /// because we may need to use gdb_objc_realized_classes until dyld is
-  /// initialized and then switch over to objc_copyRealizedClassList for lazily
-  /// named classes.
-  class DynamicClassInfoExtractor {
+  /// We potentially need both for the same process, because we may need to use
+  /// gdb_objc_realized_classes until dyld is initialized and then switch over
+  /// to objc_copyRealizedClassList for lazily named classes.
+  class DynamicClassInfoExtractor : public ClassInfoExtractor {
   public:
 DynamicClassInfoExtractor(AppleObjCRuntimeV2 &runtime)
-: m_runtime(runtime) {}
+: ClassInfoExtractor(runtime) {}
 
 enum Helper { gdb_objc_realized_classes, objc_copyRealizedClassList };
 
@@ -317,24 +328,45 @@
 UtilityFunction *GetClassInfoUtilityFunction(ExecutionContext &exe_ctx,
  Helper helper);
 lldb::addr_t &GetClassInfoArgs(Helper helper);
-std::mutex &GetMutex() { return m_mutex; }
 
   private:
 std::unique_ptr
 GetClassInfoUtilityFunctionImpl(ExecutionContext &exe_ctx, std::string code,
 std::string name);
 
-/// The lifetime of this object is tied to that of the runtime.
-AppleObjCRuntimeV2 &m_runtime;
-std::mutex m_mutex;
+/// Helper to read class info using the gdb_objc_realized_classes.
+struct gdb_objc_realized_classes_helper {
+  std::unique_ptr utility_function;
+  lldb::addr_t args = LLDB_INVALID_ADDRESS;
+};
+
+/// Helper to read class info using objc_copyRealizedClassList.
+struct objc_copyRealizedClassList_helper {
+  std::unique_ptr utility_function;
+  lldb::addr_t args = LLDB_INVALID_ADDRESS;
+};
+
+gdb_objc_realized_classes_helper m_gdb_objc_realized_classes_helper;
+objc_copyRealizedClassList_helper m_objc_copyRealizedClassList_helper;
+  };
+
+  /// Abstraction to read the Objective-C class info from the shared cache.
+  class SharedCacheClassInfoExtractor : public ClassInfoExtractor {
+  public:
+SharedCacheClassInfoExtractor(AppleObjCRuntimeV2 &runtime)
+: ClassInfoExtractor(runtime) {}
 
-/// Utility function to read class info using gdb_objc_realized_classes.
-std::unique_ptr m_get_class_info_code;
-lldb::addr_t m_get_class_info_args = LLDB_INVALID_ADDRESS;
+UtilityFunction *GetClassInfoUtilityFunction(ExecutionContext &exe_ctx);
+lldb::addr_t &GetClassInfoArgs() { return m_args; }
+std::mutex &GetMutex() { return m_mutex; }
+
+  private:
+std::unique_ptr
+GetClassInfoUtilityFunctionImpl(ExecutionContext &exe_ctx);
 
-/// Utility function to read class info using objc_copyRealizedClassList.
-std::unique_ptr m_get_class_info2_code;
-lldb::addr_t m_get_class_info2_args = LLDB_INVALID_ADDRESS;
+std::unique_ptr m_utility_function;
+lldb::addr_t m_args = LLDB_INVALID_ADDRESS;
+std::mutex m_mutex;
   };
 
   AppleObjCRuntimeV2(Process *process, const lldb::ModuleSP &objc_module_sp);
@@ -383,11 +415,8 @@
 
   lldb::ModuleSP m_objc_module_sp;
 
-  DynamicClassInfoExtractor m_class_info_extractor;
-
-  std::unique_ptr m_get_shared_cache_class_info_code;
-  lldb::ad

[Lldb-commits] [PATCH] D99448: [lldb] Move UpdateISAToDescriptorMap into ClassInfoExtractor

2021-03-26 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added a reviewer: aprantl.
JDevlieghere requested review of this revision.

Move UpdateISAToDescriptorMap into ClassInfoExtractor so that all the formerly 
public functions can be private and remain an implementation detail of the 
extractor.


https://reviews.llvm.org/D99448

Files:
  
lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h

Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
@@ -318,6 +318,10 @@
 DynamicClassInfoExtractor(AppleObjCRuntimeV2 &runtime)
 : ClassInfoExtractor(runtime) {}
 
+DescriptorMapUpdateResult
+UpdateISAToDescriptorMap(RemoteNXMapTable &hash_table);
+
+  private:
 enum Helper { gdb_objc_realized_classes, objc_copyRealizedClassList };
 
 /// Compute which helper to use. Prefer objc_copyRealizedClassList if it's
@@ -329,7 +333,6 @@
  Helper helper);
 lldb::addr_t &GetClassInfoArgs(Helper helper);
 
-  private:
 std::unique_ptr
 GetClassInfoUtilityFunctionImpl(ExecutionContext &exe_ctx, std::string code,
 std::string name);
@@ -356,17 +359,16 @@
 SharedCacheClassInfoExtractor(AppleObjCRuntimeV2 &runtime)
 : ClassInfoExtractor(runtime) {}
 
-UtilityFunction *GetClassInfoUtilityFunction(ExecutionContext &exe_ctx);
-lldb::addr_t &GetClassInfoArgs() { return m_args; }
-std::mutex &GetMutex() { return m_mutex; }
+DescriptorMapUpdateResult UpdateISAToDescriptorMap();
 
   private:
+UtilityFunction *GetClassInfoUtilityFunction(ExecutionContext &exe_ctx);
+
 std::unique_ptr
 GetClassInfoUtilityFunctionImpl(ExecutionContext &exe_ctx);
 
 std::unique_ptr m_utility_function;
 lldb::addr_t m_args = LLDB_INVALID_ADDRESS;
-std::mutex m_mutex;
   };
 
   AppleObjCRuntimeV2(Process *process, const lldb::ModuleSP &objc_module_sp);
@@ -381,14 +383,9 @@
   /// change when lazily named classes get realized.
   bool RealizedClassGenerationCountChanged();
 
-  DescriptorMapUpdateResult
-  UpdateISAToDescriptorMapDynamic(RemoteNXMapTable &hash_table);
-
   uint32_t ParseClassInfoArray(const lldb_private::DataExtractor &data,
uint32_t num_class_infos);
 
-  DescriptorMapUpdateResult UpdateISAToDescriptorMapSharedCache();
-
   enum class SharedCacheWarningReason {
 eExpressionExecutionFailure,
 eNotEnoughClassesRead
Index: lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
===
--- lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -1551,10 +1551,9 @@
 }
 
 AppleObjCRuntimeV2::DescriptorMapUpdateResult
-AppleObjCRuntimeV2::UpdateISAToDescriptorMapDynamic(
+AppleObjCRuntimeV2::DynamicClassInfoExtractor::UpdateISAToDescriptorMap(
 RemoteNXMapTable &hash_table) {
-  Process *process = GetProcess();
-
+  Process *process = m_runtime.GetProcess();
   if (process == nullptr)
 return DescriptorMapUpdateResult::Fail();
 
@@ -1583,22 +1582,20 @@
   Status err;
 
   // Compute which helper we're going to use for this update.
-  const DynamicClassInfoExtractor::Helper helper =
-  m_dynamic_class_info_extractor.ComputeHelper();
+  const DynamicClassInfoExtractor::Helper helper = ComputeHelper();
 
   // Read the total number of classes from the hash table
   const uint32_t num_classes =
   helper == DynamicClassInfoExtractor::gdb_objc_realized_classes
   ? hash_table.GetCount()
-  : m_realized_class_generation_count;
+  : m_runtime.m_realized_class_generation_count;
   if (num_classes == 0) {
 LLDB_LOGF(log, "No dynamic classes found.");
 return DescriptorMapUpdateResult::Success(0);
   }
 
   UtilityFunction *get_class_info_code =
-  m_dynamic_class_info_extractor.GetClassInfoUtilityFunction(exe_ctx,
- helper);
+  GetClassInfoUtilityFunction(exe_ctx, helper);
   if (!get_class_info_code) {
 // The callee will have already logged a useful error message.
 return DescriptorMapUpdateResult::Fail();
@@ -1629,7 +1626,7 @@
 return DescriptorMapUpdateResult::Fail();
   }
 
-  std::lock_guard guard(m_dynamic_class_info_extractor.GetMutex());
+  std::lock_guard guard(m_mutex);
 
   // Fill in our function argument values
   arguments.GetValueAtIndex(0)->GetScalar() = hash_table.GetTableLoadAddress();
@@ -1649,8 +1646,7 @@
 
   // Write our function argum

[Lldb-commits] [lldb] 24baaad - [lldb] Remove UpdateISAToDescriptorMapFromMemory

2021-03-26 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-03-26T15:40:36-07:00
New Revision: 24baaad94539553b00aceca8be5420cab943167e

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

LOG: [lldb] Remove UpdateISAToDescriptorMapFromMemory

Remove UpdateISAToDescriptorMapFromMemory because it's dead code.

Added: 


Modified: 

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

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

Removed: 




diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index 225f1af090ea..31ddf83ba988 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -1947,42 +1947,6 @@ 
AppleObjCRuntimeV2::UpdateISAToDescriptorMapSharedCache() {
   return DescriptorMapUpdateResult(success, num_class_infos);
 }
 
-bool AppleObjCRuntimeV2::UpdateISAToDescriptorMapFromMemory(
-RemoteNXMapTable &hash_table) {
-  Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS | LIBLLDB_LOG_TYPES));
-
-  Process *process = GetProcess();
-
-  if (process == nullptr)
-return false;
-
-  uint32_t num_map_table_isas = 0;
-
-  ModuleSP objc_module_sp(GetObjCModule());
-
-  if (objc_module_sp) {
-for (RemoteNXMapTable::element elt : hash_table) {
-  ++num_map_table_isas;
-
-  if (ISAIsCached(elt.second))
-continue;
-
-  ClassDescriptorSP descriptor_sp = ClassDescriptorSP(
-  new ClassDescriptorV2(*this, elt.second, elt.first.AsCString()));
-
-  if (log && log->GetVerbose())
-LLDB_LOGF(log,
-  "AppleObjCRuntimeV2 added (ObjCISA)0x%" PRIx64
-  " (%s) from dynamic table to isa->descriptor cache",
-  elt.second, elt.first.AsCString());
-
-  AddClass(elt.second, descriptor_sp, elt.first.AsCString());
-}
-  }
-
-  return num_map_table_isas > 0;
-}
-
 lldb::addr_t AppleObjCRuntimeV2::GetSharedCacheReadOnlyAddress() {
   Process *process = GetProcess();
 

diff  --git 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
index c51b1e210348..b0c1584dd369 100644
--- 
a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
+++ 
b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h
@@ -375,8 +375,6 @@ class AppleObjCRuntimeV2 : public AppleObjCRuntime {
 
   lldb::addr_t GetISAHashTablePointer();
 
-  bool UpdateISAToDescriptorMapFromMemory(RemoteNXMapTable &hash_table);
-
   /// Update the generation count of realized classes. This is not an exact
   /// count but rather a value that is incremented when new classes are 
realized
   /// or destroyed. Unlike the count in gdb_objc_realized_classes, it will



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


[Lldb-commits] [lldb] df0f9e0 - [lldb] Stop using i386 for the watchOS simulator

2021-03-26 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-03-26T17:09:45-07:00
New Revision: df0f9e044773480dbc01cf4e381af0517c930f13

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

LOG: [lldb] Stop using i386 for the watchOS simulator

This keeps breaking on my machine. It's time to move on.

Added: 


Modified: 
lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py 
b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
index d25ac26cf5fb..c0ec37910534 100644
--- a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -6,6 +6,7 @@
 
 import json
 import platform
+import re
 
 @skipIfReproducer
 class TestAppleSimulatorOSType(gdbremote_testcase.GdbRemoteTestCaseBase):
@@ -140,5 +141,4 @@ def test_simulator_ostype_tvos(self):
 @skipIfRemote
 def test_simulator_ostype_watchos(self):
 self.check_simulator_ostype(sdk='watchsimulator',
-platform_name='watchos',
-arch='i386')
+platform_name='watchos')



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


[Lldb-commits] [lldb] 38edd23 - [lldb] Fix TestAppleSimulatorOSType for older watchOS SDKs

2021-03-26 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-03-26T20:28:42-07:00
New Revision: 38edd23b8cbfc46f35bb9071e86bb66c876d371c

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

LOG: [lldb] Fix TestAppleSimulatorOSType for older watchOS SDKs

Older watchOS SDKs *only* support i386 so we can't use x86_64/arm64
unconditionally.

Added: 


Modified: 
lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py

Removed: 




diff  --git a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py 
b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
index c0ec37910534..f44955ac838a 100644
--- a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -47,9 +47,17 @@ def check_simulator_ostype(self, sdk, platform_name, 
arch=platform.machine()):
 
 # Launch the process using simctl
 self.assertIsNotNone(deviceUDID)
+
 exe_name = 'test_simulator_platform_{}'.format(platform_name)
 sdkroot = lldbutil.get_xcode_sdk_root(sdk)
 vers = lldbutil.get_xcode_sdk_version(sdk)
+
+# Older versions of watchOS (<7.0) only support i386
+if platform_name == 'watchos':
+from distutils.version import LooseVersion
+if LooseVersion(vers) < LooseVersion("7.0"):
+arch = 'i386'
+
 triple = '-'.join([arch, 'apple', platform_name + vers, 'simulator'])
 version_min = '-m{}-simulator-version-min={}'.format(platform_name, 
vers)
 self.build(



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