[Lldb-commits] [PATCH] D110535: [llvm] [ADT] Update llvm::Split() per Pavel Labath's suggestions

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

In D110535#3047033 , @joerg wrote:

> Can't you wrap `iterator_range` and possibly even support Twines like 
> that? That is, don't extend the life time of the iterators, but store it in 
> the range?

I can but @labath didn't want the extra code.


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

https://reviews.llvm.org/D110535

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


[Lldb-commits] [PATCH] D110535: [llvm] [ADT] Update llvm::Split() per Pavel Labath's suggestions

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

In D110535#3047262 , @mgorny wrote:

> In D110535#3047033 , @joerg wrote:
>
>> Can't you wrap `iterator_range` and possibly even support Twines like 
>> that? That is, don't extend the life time of the iterators, but store it in 
>> the range?
>
> I can but @labath didn't want the extra code.

I am not sure that it is worth it, but I am not completely opposed to the idea 
either. Symmetry with StringRef::split also counts for something..


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

https://reviews.llvm.org/D110535

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


Re: [Lldb-commits] [lldb] 10f16bc - Revert "[lldb] [ABI/X86] Split base x86 and i386 classes"

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

On 06/10/2021 19:57, Stella Stamenova via lldb-commits wrote:


Author: Stella Stamenova
Date: 2021-10-06T10:56:45-07:00
New Revision: 10f16bc7b2bfa0fb3589ac62fc8392854a3a2226

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

LOG: Revert "[lldb] [ABI/X86] Split base x86 and i386 classes"

This change broke the windows lldb bot.



Is there a plan to do something about the flakyness of that bot? 
Currently, it's success rate is like 80%. At that rate, people will 
train themselves to ignore it even if they do get a notification (which 
did not happen here because the previous build was a flake).


Maybe just disable the test step? Or just make the test step not fail 
the build (IIRC, buildbot has that option) ?


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


[Lldb-commits] [PATCH] D111295: [lldb] [Target] Make addSupplementaryRegister() work on RRI vector

2021-10-07 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, teemperor, krytarowski, emaste.
mgorny requested review of this revision.

Move DynamicRegisterInfo::AddSupplementaryRegister() into a standalone
function working on std::vector.  This will make it
possible to use it without DynamicRegisterInfo.


https://reviews.llvm.org/D111295

Files:
  lldb/include/lldb/Target/DynamicRegisterInfo.h
  lldb/include/lldb/Target/RemoteRegisterInfo.h
  lldb/source/Target/CMakeLists.txt
  lldb/source/Target/DynamicRegisterInfo.cpp
  lldb/source/Target/RemoteRegisterInfo.cpp
  lldb/unittests/Target/CMakeLists.txt
  lldb/unittests/Target/DynamicRegisterInfoTest.cpp
  lldb/unittests/Target/RemoteRegisterInfoTest.cpp

Index: lldb/unittests/Target/RemoteRegisterInfoTest.cpp
===
--- /dev/null
+++ lldb/unittests/Target/RemoteRegisterInfoTest.cpp
@@ -0,0 +1,79 @@
+//===-- RemoteRegisterInfoTest.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 "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+#include "lldb/Target/RemoteRegisterInfo.h"
+
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+
+class RemoteRegisterInfoTest : public ::testing::Test {
+protected:
+  std::vector regs;
+
+  uint32_t
+  AddTestRegister(const char *name, const char *group, uint32_t byte_size,
+  std::function adder,
+  std::vector value_regs = {},
+  std::vector invalidate_regs = {}) {
+RemoteRegisterInfo new_reg{ConstString(name), ConstString(),
+   ConstString(group),byte_size,
+   LLDB_INVALID_INDEX32,  lldb::eEncodingUint,
+   lldb::eFormatUnsigned, LLDB_INVALID_REGNUM,
+   LLDB_INVALID_REGNUM,   LLDB_INVALID_REGNUM,
+   LLDB_INVALID_REGNUM,   value_regs,
+   invalidate_regs};
+adder(new_reg);
+return regs.size() - 1;
+  }
+
+  void AssertRegisterInfo(uint32_t reg_num, const char *reg_name,
+  std::vector value_regs = {},
+  std::vector invalidate_regs = {}) {
+EXPECT_GT(regs.size(), reg_num);
+if (regs.size() <= reg_num)
+  return;
+
+const RemoteRegisterInfo ® = regs[reg_num];
+ConstString expected_reg_name{reg_name};
+EXPECT_EQ(reg.name, expected_reg_name);
+EXPECT_EQ(reg.value_regs, value_regs);
+EXPECT_EQ(reg.invalidate_regs, invalidate_regs);
+  }
+};
+
+#define ASSERT_REG(reg, ...)   \
+  {\
+SCOPED_TRACE("at register " #reg); \
+AssertRegisterInfo(reg, #reg, __VA_ARGS__);\
+  }
+
+TEST_F(RemoteRegisterInfoTest, addSupplementaryRegister) {
+  // Add a base register
+  uint32_t rax =
+  AddTestRegister("rax", "group", 8, [this](const RemoteRegisterInfo &r) {
+regs.push_back(r);
+  });
+
+  // Add supplementary registers
+  auto suppl_adder = [this](const RemoteRegisterInfo &r) {
+addSupplementaryRegister(regs, r);
+  };
+  uint32_t eax = AddTestRegister("eax", "supplementary", 4, suppl_adder, {rax});
+  uint32_t ax = AddTestRegister("ax", "supplementary", 2, suppl_adder, {rax});
+  uint32_t al = AddTestRegister("al", "supplementary", 1, suppl_adder, {rax});
+
+  ASSERT_REG(rax, {}, {eax, ax, al});
+  ASSERT_REG(eax, {rax}, {rax, ax, al});
+  ASSERT_REG(ax, {rax}, {rax, eax, al});
+  ASSERT_REG(al, {rax}, {rax, eax, ax});
+}
Index: lldb/unittests/Target/DynamicRegisterInfoTest.cpp
===
--- lldb/unittests/Target/DynamicRegisterInfoTest.cpp
+++ lldb/unittests/Target/DynamicRegisterInfoTest.cpp
@@ -123,47 +123,3 @@
   ASSERT_REG(i1, LLDB_INVALID_INDEX32);
   ASSERT_REG(i2, LLDB_INVALID_INDEX32);
 }
-
-TEST_F(DynamicRegisterInfoTest, add_supplementary_register) {
-  // Add a base register
-  uint32_t rax = AddTestRegister("rax", 8);
-
-  // Register numbers
-  uint32_t eax = 1;
-  uint32_t ax = 2;
-  uint32_t al = 3;
-
-  ConstString group{"supplementary registers"};
-  uint32_t value_regs[2] = {rax, LLDB_INVALID_REGNUM};
-  struct RegisterInfo eax_reg {
-"eax", nullptr, 4, LLDB_INVALID_INDEX32, lldb::eEncodingUint,
-lldb::eFormatUnsigned,
-{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, eax,
- eax},
-value_regs, nullptr
-  };
-  info.AddSupplementaryRegister(eax_reg, group);
-
-  struct RegisterInfo ax_reg {
-"ax", nullptr

[Lldb-commits] [PATCH] D96236: [lldb] DWZ 09/17: Include main unit DWARFUnit * inside DWARFDIEs

2021-10-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil abandoned this revision.
jankratochvil added a comment.

I will be no longer involved with this patchset.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96236

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


[Lldb-commits] [PATCH] D96236: [lldb] DWZ 09/17: Pass main DWARFUnit * along DWARFDIEs

2021-10-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil updated this revision to Diff 374770.
jankratochvil retitled this revision from "[lldb] DWZ 1/9: Pass main DWARFUnit 
* along DWARFDIEs" to "[lldb] DWZ 09/17: Pass main DWARFUnit * along DWARFDIEs".
Herald added a subscriber: mgorny.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96236

Files:
  lldb/include/lldb/Expression/DWARFExpression.h
  lldb/source/Expression/DWARFExpression.cpp
  lldb/source/Plugins/SymbolFile/DWARF/CMakeLists.txt
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFSimpleDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFSimpleDIE.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnitPair.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnitPair.h
  lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/DWARFLocationExpression.cpp
  lldb/source/Plugins/SymbolFile/PDB/PDBLocationToDWARFExpression.cpp
  lldb/source/Target/RegisterContext.cpp
  lldb/source/Target/RegisterContextUnwind.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp
  lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
  lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
  lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp

Index: lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
===
--- lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
+++ lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
@@ -43,7 +43,7 @@
   ASSERT_TRUE((bool)t.GetDwarfUnit());
 
   DWARFUnit *unit = t.GetDwarfUnit();
-  const DWARFDebugInfoEntry *die_first = unit->DIE().GetDIE();
+  const DWARFDebugInfoEntry *die_first = unit->DIE(unit).GetDIE();
   ASSERT_NE(die_first, nullptr);
   EXPECT_TRUE(die_first->IsNULL());
 }
@@ -79,7 +79,7 @@
   ASSERT_TRUE((bool)t.GetDwarfUnit());
 
   DWARFUnit *unit = t.GetDwarfUnit();
-  const DWARFDebugInfoEntry *die_first = unit->DIE().GetDIE();
+  const DWARFDebugInfoEntry *die_first = unit->DIE(unit).GetDIE();
   ASSERT_NE(die_first, nullptr);
   EXPECT_EQ(die_first->GetFirstChild(), nullptr);
   EXPECT_EQ(die_first->GetSibling(), nullptr);
Index: lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
===
--- lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
+++ lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp
@@ -68,7 +68,7 @@
   ASSERT_TRUE((bool)t.GetDwarfUnit());
 
   DWARFUnit *unit = t.GetDwarfUnit();
-  const DWARFDebugInfoEntry *die_first = unit->DIE().GetDIE();
+  const DWARFDebugInfoEntry *die_first = unit->DIE(unit).GetDIE();
 
   // Create a DWARFDIE that has three DW_TAG_base_type children.
   DWARFDIE top_die(unit, die_first);
Index: lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
===
--- lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
+++ lldb/unittests/SymbolFile/DWARF/DWARFASTParserClangTests.cpp
@@ -96,7 +96,7 @@
   DWARFASTParserClangStub ast_parser(ast_ctx);
 
   DWARFUnit *unit = t.GetDwarfUnit();
-  const DWARFDebugInfoEntry *die_first = unit->DIE().GetDIE();
+  const DWARFDebugInfoEntry *die_first = unit->DIE(unit).GetDIE();
   const DWARFDebugInfoEntry *die_child0 = die_first->GetFirstChild();
   const DWARFDebugInfoEntry *die_child1 = die_child0->GetSibling();
   const DWARFDebugInfoEntry *die_child2 = die_child1->GetSibling();
Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ lldb/unittests/Expression/DWARFExpressionTest.cpp
@@ -25,7 +25,7 @@
 
 static llvm::Expected Evaluate(llvm::ArrayRef expr,
   

[Lldb-commits] [PATCH] D96236: [lldb] DWZ 1/9: Pass main DWARFUnit * along DWARFDIEs

2021-10-07 Thread Jan Kratochvil via Phabricator via lldb-commits
jankratochvil added a comment.

Asking LLDB community whether to continue with this patchset upstreaming:
Its advantage is sure compatibility with DWZ being used by {RHEL,CentOS}-{7,8}. 
The next version of {RHEL,CentOS} will use it as well. By my quick check Debian 
12=Bookworm=testing is not using DWZ but Debian Sid=unstable is using DWZ. DWZ 
is applied for debug info packages supplied by system vendors. DWZ is not 
automatically applied for binaries compiled by the user.
The disadvantage is that it complicates LLDB codebase IMO a lot (I haven't 
found a less intrusive way to implement the DWZ compatibility) and the debug 
info size reduction by DWZ is IMO too small to be worth all the LLDB codebase 
complications. There could be for example much easier DWZ decompressor (it does 
not exist now) for compatibility reasons instead. For current and future the 
DWZ optimization has been IMO superseded by `clang -flto`. (I have no numbers 
for that claim).
My employer wants this patchset for DWZ support to be upstream in LLDB. 
Personally I am against this idea for reasons in the paragraph above, that 
complicating LLDB codebase is not worth only backward compatibility reasons. 
IMO nowadays DWZ has been superseded by LTO, size advantages of separate 
`*.debug` files download and less importance of small file size difference 
compared to software engineering simplicity.
I spent 2 months measuring effects of DWZ on Fedora/CentOS distribution size 
(the benchmarking code 
): For 
`*-debuginfo.rpm` size storage compared to `-fdebug-types-section` I did 
measure in average 5% size reduction in favor of DWZ but with stddev of +/-11% 
of the size. That means the size reduction strongly depends on which packages 
are chosen. For example for package subset of Fedora which is in CentOS the 
size reduction is only 0.28%. Another example is Fedora subset of packages I 
have installed where DWZ `*-debuginfo.rpm` is even 0.72% bigger than 
`-fdebug-types-section`.
DWZ 5% saving saves about 5GB of the 82GB debug info size per Fedora Linux 
distribution. Personally I find it all pointless as it is one 4K movie size and 
nobody is downloading all the distribution debug info anyway.
Nowadays with `-flto` I believe the size is even smaller than 
`-fdebug-types-section` (and therefore the DWZ size advantage is worse) but I 
have no numbers for this claim.
The average 5% size reduction on `*-debuginfo.rpm` is primarily thanks to DWZ 
DWARF-5 "7.3.6 DWARF Supplementary Object Files". While that is useful for 
`*-debuginfo.rpm` size with the move from downloading whole `*-debuginfo.rpm` 
to rather download separate `*.debug` files (for example by debuginfod 
) one then has to download 
more data with DWZ rather than less (it depends how many files from the same 
package one downloads etc.).
The problem of the current DWZ file format is that one cannot parse 
`DW_UT_partial` without having its `DW_UT_compile` (containing 
`DW_TAG_imported_unit` for that `DW_UT_partial`) as `DW_UT_partial` is missing 
`DW_AT_language`. Another problem is that "DWARF Supplementary Object Files" 
can contain not just the typical types (like `DW_UT_type` although for DWZ in 
`DW_UT_partial`) but it can contain also `static const int variable=42;' which 
does not need `DW_AT_location`. According to @clayborg LLVM IR for types could 
be imported across files but not the variables (for variables we also need to 
know the parent `DW_UT_compile` when parsing them). This all makes the need to 
carry `DWARFUnit *main_unit` (usually as a part of `DWARFUnitPair`) everywhere 
across the LLDB codebase.
There could be a new file format not using `DW_UT_partial` but with "DWARF 
Supplementary Object Files" containing only `DW_UT_type` units which would have 
with LTO IMO the same `*-debuginfo.rpm` size benefits as DWZ without the 
difficulty to carry `DWARFUnit *main_unit` everywhere. But then such simplified 
LLDB reader would no longer be compatible with existing Red Hat OSes debug info 
formats which Red Hat is therefore not interested in.
There are many more effective debug info size reductions already supported by 
upstream LLDB. For example `SHF_COMPRESS` (`zlib`) saves 52% (compared to 5% of 
DWZ). One could also use `zstd` for faster decompression. That is for installed 
on-disk size (other measurements here are for `*-debuginfo.rpm` size).
If the debug info size matters LLVM could use more optimal `DW_FORM_ref*` than 
just its current `DW_FORM_ref4`. This is one of the optimizations done by DWZ.
I have removed all memory storage of `DWARFDIE` so that non-DWZ systems do not 
have performance affected by the DWZ compatibility of LLDB due to the increased 
size of `DWARFDIE` 16 bytes -> 24 bytes due to the new 
`DWARFDIE::m_cu::m_main_cu`. Still there remains a question how such 
`llvm::DWARFDie` size increase would be accepted by LLVM if the DWARF merge 

[Lldb-commits] [PATCH] D109876: [lldb] [ABI/AArch64] Add pseudo-regs if missing

2021-10-07 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 377792.
mgorny added a comment.

Rewrite for `std::vector`-based augmentation.


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

https://reviews.llvm.org/D109876

Files:
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
  lldb/source/Target/DynamicRegisterInfo.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -380,6 +380,7 @@
 return "".join(reg_data)
 
 def writeRegisters(self, reg_hex):
+reg_data[:] = [reg_hex]
 return "OK"
 
 def haltReason(self):
@@ -429,3 +430,43 @@
["v0 = {0x81 0x82 0x83 0x84 0x85 0x86 0x87 0x88 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90}"])
 self.match("register read v31",
["v31 = {0xa1 0xa2 0xa3 0xa4 0xa5 0xa6 0xa7 0xa8 0xa9 0xaa 0xab 0xac 0xad 0xae 0xaf 0xb0}"])
+
+# test partial registers
+self.match("register read w0",
+   ["w0 = 0x04030201"])
+self.runCmd("register write w0 0xfffefdfc")
+self.match("register read x0",
+   ["x0 = 0x08070605fffefdfc"])
+
+self.match("register read w1",
+   ["w1 = 0x14131211"])
+self.runCmd("register write w1 0xefeeedec")
+self.match("register read x1",
+   ["x1 = 0x18171615efeeedec"])
+
+self.match("register read w30",
+   ["w30 = 0x44434241"])
+self.runCmd("register write w30 0xdfdedddc")
+self.match("register read x30",
+   ["x30 = 0x48474645dfdedddc"])
+
+self.match("register read w31",
+   ["w31 = 0x54535251"])
+self.runCmd("register write w31 0xcfcecdcc")
+self.match("register read x31",
+   ["sp = 0x58575655cfcecdcc"])
+
+# test FPU registers (overlapping with vector registers)
+self.runCmd("register write d0 16")
+self.match("register read v0",
+   ["v0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x30 0x40 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90}"])
+self.runCmd("register write v31 '{0x00 0x00 0x00 0x00 0x00 0x00 0x50 0x40 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff}'")
+self.match("register read d31",
+   ["d31 = 64"])
+
+self.runCmd("register write s0 32")
+self.match("register read v0",
+   ["v0 = {0x00 0x00 0x00 0x42 0x00 0x00 0x30 0x40 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90}"])
+self.runCmd("register write v31 '{0x00 0x00 0x00 0x43 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff}'")
+self.match("register read s31",
+   ["s31 = 128"])
Index: lldb/source/Target/DynamicRegisterInfo.cpp
===
--- lldb/source/Target/DynamicRegisterInfo.cpp
+++ lldb/source/Target/DynamicRegisterInfo.cpp
@@ -780,16 +780,18 @@
 
 const lldb_private::RegisterInfo *
 DynamicRegisterInfo::GetRegisterInfo(llvm::StringRef reg_name) const {
+  assert(!reg_name.empty());
   for (auto ®_info : m_regs)
-if (reg_info.name == reg_name)
+if (reg_info.name == reg_name || reg_info.alt_name == reg_name)
   return ®_info;
   return nullptr;
 }
 
 lldb_private::RegisterInfo *
 DynamicRegisterInfo::GetRegisterInfo(llvm::StringRef reg_name) {
+  assert(!reg_name.empty());
   for (auto ®_info : m_regs)
-if (reg_info.name == reg_name)
+if (reg_info.name == reg_name || reg_info.alt_name == reg_name)
   return ®_info;
   return nullptr;
 }
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -71,14 +71,94 @@
   .Default(LLDB_INVALID_REGNUM);
 }
 
+static void
+AddPartialRegister(std::vector ®s,
+   uint32_t full_reg_index, uint32_t full_reg_size,
+   const std::string &partial_reg_name,
+   uint32_t partial_reg_size, lldb::Encoding encoding,
+   lldb::Format format, uint32_t &next_regnum_lldb) {
+  if (full_reg_index == LLDB_INVALID_REGNUM ||
+  regs[full_reg_index].byte_size != full_reg_size)
+return;
+
+  lldb_private::RemoteRegisterInfo partial_reg{
+  lldb_private::ConstString(partial_reg_name),
+  lldb_private::ConstString(),
+  lldb_private::ConstString("partial registers"),
+  partial_reg_size,
+  LLDB_INVALID_INDEX32,
+  encoding,
+  format,
+  LLDB_INVALID_REGNUM,
+  LLDB_INVALID_REGNUM,
+  LLDB_INVALID_REGNUM,
+  LLDB_INVALID_REGNUM,
+

[Lldb-commits] [lldb] 81a2f39 - [lldb/gdb-remote] Delete SendPacketsAndConcatenateResponses

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

Author: Pavel Labath
Date: 2021-10-07T13:09:27+02:00
New Revision: 81a2f39307a1f2169203abeb66c7bb00b5496edc

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

LOG: [lldb/gdb-remote] Delete SendPacketsAndConcatenateResponses

ReadExtFeature provides equivalent functionality. Also fix a but in
ReadExtFeature, which prevented it from being used for auxv data (it
contains nul characters).

Added: 


Modified: 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index a44e666427899..e49bf22512cf3 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -686,54 +686,6 @@ bool GDBRemoteCommunicationClient::GetxPacketSupported() {
   return m_supports_x;
 }
 
-GDBRemoteCommunicationClient::PacketResult
-GDBRemoteCommunicationClient::SendPacketsAndConcatenateResponses(
-const char *payload_prefix, std::string &response_string) {
-  Lock lock(*this);
-  if (!lock) {
-Log *log(ProcessGDBRemoteLog::GetLogIfAnyCategoryIsSet(GDBR_LOG_PROCESS |
-   GDBR_LOG_PACKETS));
-LLDB_LOGF(log,
-  "error: failed to get packet sequence mutex, not sending "
-  "packets with prefix '%s'",
-  payload_prefix);
-return PacketResult::ErrorNoSequenceLock;
-  }
-
-  response_string = "";
-  std::string payload_prefix_str(payload_prefix);
-  unsigned int response_size = 0x1000;
-  if (response_size > GetRemoteMaxPacketSize()) { // May send qSupported packet
-response_size = GetRemoteMaxPacketSize();
-  }
-
-  for (unsigned int offset = 0; true; offset += response_size) {
-StringExtractorGDBRemote this_response;
-// Construct payload
-char sizeDescriptor[128];
-snprintf(sizeDescriptor, sizeof(sizeDescriptor), "%x,%x", offset,
- response_size);
-PacketResult result = SendPacketAndWaitForResponseNoLock(
-payload_prefix_str + sizeDescriptor, this_response);
-if (result != PacketResult::Success)
-  return result;
-
-const std::string &this_string = std::string(this_response.GetStringRef());
-
-// Check for m or l as first character; l seems to mean this is the last
-// chunk
-char first_char = *this_string.c_str();
-if (first_char != 'm' && first_char != 'l') {
-  return PacketResult::ErrorReplyInvalid;
-}
-// Concatenate the result so far (skipping 'm' or 'l')
-response_string.append(this_string, 1, std::string::npos);
-if (first_char == 'l')
-  // We're done
-  return PacketResult::Success;
-  }
-}
-
 lldb::pid_t GDBRemoteCommunicationClient::GetCurrentProcessID(bool allow_lazy) 
{
   if (allow_lazy && m_curr_pid_is_valid == eLazyBoolYes)
 return m_curr_pid;
@@ -3982,8 +3934,7 @@ bool GDBRemoteCommunicationClient::ReadExtFeature(
 
 // more chunks
 case ('m'):
-  if (str.length() > 1)
-output << &str[1];
+  output << str.substr(1);
   offset += str.length() - 1;
   break;
 

diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
index fd3fe1ce29969..9b8b4cb887056 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
@@ -65,27 +65,6 @@ class GDBRemoteCommunicationClient : public 
GDBRemoteClientBase {
   // we are communicating with it.
   bool HandshakeWithServer(Status *error_ptr);
 
-  // For packets which specify a range of output to be returned,
-  // return all of the output via a series of request packets of the form
-  // 0,
-  // ,
-  // *2,
-  // *3,
-  // ...
-  // until a "$l..." packet is received, indicating the end.
-  // (size is in hex; this format is used by a standard gdbserver to
-  // return the given portion of the output specified by ;
-  // for example, "qXfer:libraries-svr4:read::fff,1000" means
-  // "return a chunk of the xml description file for shared
-  // library load addresses, where the chunk starts at offset 0xfff
-  // and continues for 0x1000 bytes").
-  // Concatenate the resulting server response packets together and
-  // return in response_string.  If any packet fails, the return value
-  // indicates that failure and the returned string value is undefined.
-  PacketResult
-  SendPacketsAndConcatenat

[Lldb-commits] [lldb] 322e13b - [lldb] Rewrite/expand TestCppTypedef and document a lookup bug.

2021-10-07 Thread Raphael Isemann via lldb-commits

Author: Raphael Isemann
Date: 2021-10-07T13:30:03+02:00
New Revision: 322e13b91aac23ab324c3dcbbcfe8e73894f4c28

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

LOG: [lldb] Rewrite/expand TestCppTypedef and document a lookup bug.

Just regrouping the checks for the same typedef together and also giving the
different typedefs unique names. We might want to have a second test with
identical names to see how LLDB handle the potential name conflict, but that
should be a separate test and not part of the main typedef test.

Also this test is actually unintentionally passing. LLDB can't lookup typedefs
in a struct/class scope, but in the test the check passes as the local variable
in the expression evaluation scope pulls in the typedef. I added a second check
that makes it clear that this is not working right now.

Added: 


Modified: 
lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
lldb/test/API/lang/cpp/typedef/main.cpp

Removed: 




diff  --git a/lldb/test/API/lang/cpp/typedef/TestCppTypedef.py 
b/lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
index 35a2fba7ca9db..f3f54a816e69e 100644
--- a/lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
+++ b/lldb/test/API/lang/cpp/typedef/TestCppTypedef.py
@@ -1,63 +1,89 @@
 """
-Test that we can retrieve typedefed types correctly
+Test typedef types.
 """
 
-
-
 import lldb
 import lldbsuite.test.lldbutil as lldbutil
 from lldbsuite.test.lldbtest import *
 from lldbsuite.test import decorators
 
+
 class TestCppTypedef(TestBase):
 
 mydir = TestBase.compute_mydir(__file__)
 
 def test_typedef(self):
 """
-Test that we retrieve typedefed types correctly
+Test that we retrieve typedefed types correctly
 """
 
-# Build and run until the breakpoint
 self.build()
 self.main_source_file = lldb.SBFileSpec("main.cpp")
-(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
-self, "Set a breakpoint here", self.main_source_file)
+lldbutil.run_to_source_breakpoint(
+self, "Set a breakpoint here", lldb.SBFileSpec("main.cpp")
+)
 
-# Get the current frame
-frame = thread.GetSelectedFrame()
 
-# First of all, check that we can get a typedefed type correctly in a 
simple case
+# First of all, check that we can get a typedefed type correctly in a 
simple case.
+expr_result = self.expect_expr(
+"(GlobalTypedef)s",
+result_type="GlobalTypedef",
+result_children=[ValueCheck(value="0.5")],
+)
 
-expr_result = self.expect_expr("(SF)s", 
result_children=[ValueCheck(value="0.5")])
-self.expect_expr("(ns::SF)s", 
result_children=[ValueCheck(value="0.5")])
-self.expect_expr("(ST::SF)s", 
result_children=[ValueCheck(value="0.5")])
-
-self.filecheck("image dump ast a.out", __file__, "--strict-whitespace")
-# CHECK:  {{^}}|-TypedefDecl {{.*}} SF 'S'
-# CHECK:  {{^}}|-NamespaceDecl {{.*}} ns
-# CHECK-NEXT: {{^}}| `-TypedefDecl {{.*}} SF 'S'
-# CHECK:  {{^}}`-CXXRecordDecl {{.*}} struct ST definition
-# CHECK:  {{^}}  `-TypedefDecl {{.*}} SF 'S'
-
-typedef_type = expr_result.GetType();
-self.assertTrue(typedef_type.IsValid(), "Can't get `SF` type of 
evaluated expression")
-self.assertTrue(typedef_type.IsTypedefType(), "Type `SF` should be a 
typedef")
+# The type should be a typedef.
+typedef_type = expr_result.GetType()
+self.assertTrue(typedef_type.IsValid())
+self.assertTrue(typedef_type.IsTypedefType())
 
+# The underlying type should be S.
 typedefed_type = typedef_type.GetTypedefedType()
-self.assertTrue(typedefed_type.IsValid(), "Can't get `SF` typedefed 
type")
-self.assertEqual(typedefed_type.GetName(), "S", "Got invalid 
`SF` typedefed type")
+self.assertTrue(typedefed_type.IsValid())
+self.assertEqual(typedefed_type.GetName(), "S")
+
 
 # Check that we can get a typedefed type correctly in the case
 # when an elaborated type is created during the parsing
+expr_result = self.expect_expr(
+"(GlobalTypedef::V)s.value", result_type="GlobalTypedef::V"
+)
 
-expr_result = frame.EvaluateExpression("(SF::V)s.value")
-self.assertTrue(expr_result.IsValid(), "Expression failed with: " + 
str(expr_result.GetError()))
-
-typedef_type = expr_result.GetType();
-self.assertTrue(typedef_type.IsValid(), "Can't get `SF::V` type of 
evaluated expression")
-self.assertTrue(typedef_type.IsTypedefType(), "Type `SF::V` should be 
a typedef")
+# The type should be a typedef.
+typedef_type = expr_result.GetType()
+   

[Lldb-commits] [PATCH] D111295: [lldb] [Target] Make addSupplementaryRegister() work on RRI vector

2021-10-07 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

Looks good. I'm not sure about the RemoteRegisterInfo name, but that's a topic 
for the patch that introduces it.


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

https://reviews.llvm.org/D111295

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


[Lldb-commits] [PATCH] D111142: [lldb] [ABI] Apply AugmentRegisterInfo() to RemoteRegisterInfos

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

I like everything except the class name. :)

I don't think it makes sense in the new location, and ideally I'd like to also 
use this for other plugins in the future (so that e.g. core file plugins don't 
have to excruciatingly list everything). Maybe we could move it into the the 
DynamicRegisterInfo class (as the intended use is to convert it to that 
eventually), and give it some generic name like `Register` or  `Descriptor` or 
`RegisterDescriptor` ?




Comment at: lldb/include/lldb/Target/DynamicRegisterInfo.h:80-82
+  lldb_private::RegisterInfo *
+  GetRegisterInfo(llvm::StringRef reg_name);
+

What's up with this?


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

https://reviews.llvm.org/D42

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


[Lldb-commits] [PATCH] D111209: Don't push null ExecutionContext on CommandInterpreter exectx stack

2021-10-07 Thread Tatyana Krasnukha via Phabricator via lldb-commits
tatyana-krasnukha added a comment.

Added inline comment




Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:2842
 
-  OverrideExecutionContext(m_debugger.GetSelectedExecutionContext());
-  auto finalize = llvm::make_scope_exit([this]() {
-RestoreExecutionContext();
+  ExecutionContext exe_ctx = m_debugger.GetSelectedExecutionContext();
+  bool pushed_exe_ctx = false;

The intention of overriding the context here with the currently selected one 
was to have the same context during `HandleCommand` and `GetProcessOutput`. 
However, this logic looks wrong to me now. `HandleCommand` may change the 
context and `GetProcessOutput` should use the new one. I think that you can 
safely remove this piece of code (untill `IOHandlerInputComplete` doesn't allow 
overriding execution context).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111209

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


[Lldb-commits] [PATCH] D111142: [lldb] [ABI] Apply AugmentRegisterInfo() to RemoteRegisterInfos

2021-10-07 Thread Michał Górny via Phabricator via lldb-commits
mgorny marked an inline comment as done.
mgorny added inline comments.



Comment at: lldb/include/lldb/Target/DynamicRegisterInfo.h:80-82
+  lldb_private::RegisterInfo *
+  GetRegisterInfo(llvm::StringRef reg_name);
+

labath wrote:
> What's up with this?
Probably leftover from the previous version. I need to double-check if no other 
commit requires that.


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

https://reviews.llvm.org/D42

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


[Lldb-commits] [PATCH] D111142: [lldb] [ABI] Apply AugmentRegisterInfo() to DynamicRegisterInfo::Registers

2021-10-07 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 377831.
mgorny marked an inline comment as done.
mgorny retitled this revision from "[lldb] [ABI] Apply AugmentRegisterInfo() to 
RemoteRegisterInfos" to "[lldb] [ABI] Apply AugmentRegisterInfo() to 
DynamicRegisterInfo::Registers".
mgorny edited the summary of this revision.
mgorny added a comment.

Move/rename `RemoteRegisterInfo` to `DynamicRegisterInfo::Register`. Remove 
leftover DRI changes.


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

https://reviews.llvm.org/D42

Files:
  lldb/include/lldb/Target/ABI.h
  lldb/include/lldb/Target/DynamicRegisterInfo.h
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
  lldb/source/Target/ABI.cpp

Index: lldb/source/Target/ABI.cpp
===
--- lldb/source/Target/ABI.cpp
+++ lldb/source/Target/ABI.cpp
@@ -214,33 +214,39 @@
   return info_up;
 }
 
-void RegInfoBasedABI::AugmentRegisterInfo(RegisterInfo &info) {
-  if (info.kinds[eRegisterKindEHFrame] != LLDB_INVALID_REGNUM &&
-  info.kinds[eRegisterKindDWARF] != LLDB_INVALID_REGNUM)
-return;
-
-  RegisterInfo abi_info;
-  if (!GetRegisterInfoByName(info.name, abi_info))
-return;
-
-  if (info.kinds[eRegisterKindEHFrame] == LLDB_INVALID_REGNUM)
-info.kinds[eRegisterKindEHFrame] = abi_info.kinds[eRegisterKindEHFrame];
-  if (info.kinds[eRegisterKindDWARF] == LLDB_INVALID_REGNUM)
-info.kinds[eRegisterKindDWARF] = abi_info.kinds[eRegisterKindDWARF];
-  if (info.kinds[eRegisterKindGeneric] == LLDB_INVALID_REGNUM)
-info.kinds[eRegisterKindGeneric] = abi_info.kinds[eRegisterKindGeneric];
+void RegInfoBasedABI::AugmentRegisterInfo(
+std::vector ®s) {
+  for (DynamicRegisterInfo::Register &info : regs) {
+if (info.regnum_ehframe != LLDB_INVALID_REGNUM &&
+info.regnum_dwarf != LLDB_INVALID_REGNUM)
+  continue;
+
+RegisterInfo abi_info;
+if (!GetRegisterInfoByName(info.name.GetStringRef(), abi_info))
+  continue;
+
+if (info.regnum_ehframe == LLDB_INVALID_REGNUM)
+  info.regnum_ehframe = abi_info.kinds[eRegisterKindEHFrame];
+if (info.regnum_dwarf == LLDB_INVALID_REGNUM)
+  info.regnum_dwarf = abi_info.kinds[eRegisterKindDWARF];
+if (info.regnum_generic == LLDB_INVALID_REGNUM)
+  info.regnum_generic = abi_info.kinds[eRegisterKindGeneric];
+  }
 }
 
-void MCBasedABI::AugmentRegisterInfo(RegisterInfo &info) {
-  uint32_t eh, dwarf;
-  std::tie(eh, dwarf) = GetEHAndDWARFNums(info.name);
-
-  if (info.kinds[eRegisterKindEHFrame] == LLDB_INVALID_REGNUM)
-info.kinds[eRegisterKindEHFrame] = eh;
-  if (info.kinds[eRegisterKindDWARF] == LLDB_INVALID_REGNUM)
-info.kinds[eRegisterKindDWARF] = dwarf;
-  if (info.kinds[eRegisterKindGeneric] == LLDB_INVALID_REGNUM)
-info.kinds[eRegisterKindGeneric] = GetGenericNum(info.name);
+void MCBasedABI::AugmentRegisterInfo(
+std::vector ®s) {
+  for (DynamicRegisterInfo::Register &info : regs) {
+uint32_t eh, dwarf;
+std::tie(eh, dwarf) = GetEHAndDWARFNums(info.name.GetStringRef());
+
+if (info.regnum_ehframe == LLDB_INVALID_REGNUM)
+  info.regnum_ehframe = eh;
+if (info.regnum_dwarf == LLDB_INVALID_REGNUM)
+  info.regnum_dwarf = dwarf;
+if (info.regnum_generic == LLDB_INVALID_REGNUM)
+  info.regnum_generic = GetGenericNum(info.name.GetStringRef());
+  }
 }
 
 std::pair
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -19,6 +19,7 @@
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/ThreadSafeValue.h"
 #include "lldb/Host/HostThread.h"
+#include "lldb/Target/DynamicRegisterInfo.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Utility/ArchSpec.h"
@@ -44,22 +45,6 @@
 }
 namespace process_gdb_remote {
 
-struct RemoteRegisterInfo {
-  ConstString name;
-  ConstString alt_name;
-  ConstString set_name;
-  uint32_t byte_size = LLDB_INVALID_INDEX32;
-  uint32_t byte_offset = LLDB_INVALID_INDEX32;
-  lldb::Encoding encoding = lldb::eEncodingUint;
-  lldb::Format format = lldb::eFormatHex;
-  uint32_t regnum_dwarf = LLDB_INVALID_REGNUM;
-  uint32_t regnum_ehframe = LLDB_INVALID_REGNUM;
-  uint32_t regnum_generic = LLDB_INVALID_REGNUM;
-  uint32_t regnum_remote = LLDB_INVALID_REGNUM;
-  std::vector value_regs;
-  std::vector invalidate_regs;
-};
-
 class ThreadGDBRemote;
 
 class ProcessGDBRemote : public Process,
@@ -411,11 +396,11 @@
 
   bool GetGDBServerRegisterInfoXMLAndProcess(
 ArchSpec &arch_to_use, std::string xml_filename,
-std::vector ®isters);
+std::vector ®isters);
 
-  // Convert RemoteRegisterInfos into RegisterInfos and add 

[Lldb-commits] [PATCH] D111295: [lldb] [Target] Make addSupplementaryRegister() work on Register vector

2021-10-07 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 377833.
mgorny retitled this revision from "[lldb] [Target] Make 
addSupplementaryRegister() work on RRI vector" to "[lldb] [Target] Make 
addSupplementaryRegister() work on Register vector".
mgorny edited the summary of this revision.
mgorny added a comment.

Rebase after renaming RRI to DRI::Register.


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

https://reviews.llvm.org/D111295

Files:
  lldb/include/lldb/Target/DynamicRegisterInfo.h
  lldb/source/Target/DynamicRegisterInfo.cpp
  lldb/unittests/Target/DynamicRegisterInfoTest.cpp

Index: lldb/unittests/Target/DynamicRegisterInfoTest.cpp
===
--- lldb/unittests/Target/DynamicRegisterInfoTest.cpp
+++ lldb/unittests/Target/DynamicRegisterInfoTest.cpp
@@ -12,6 +12,8 @@
 #include "lldb/Target/DynamicRegisterInfo.h"
 #include "lldb/Utility/ArchSpec.h"
 
+#include 
+
 using namespace lldb_private;
 
 static std::vector regs_to_vector(uint32_t *regs) {
@@ -69,9 +71,10 @@
   }
 };
 
-#define ASSERT_REG(reg, ...) { \
-  SCOPED_TRACE("at register " #reg); \
-  AssertRegisterInfo(reg, #reg, __VA_ARGS__); \
+#define ASSERT_REG(reg, ...)   \
+  {\
+SCOPED_TRACE("at register " #reg); \
+AssertRegisterInfo(reg, #reg, __VA_ARGS__);\
   }
 
 TEST_F(DynamicRegisterInfoTest, finalize_regs) {
@@ -124,46 +127,64 @@
   ASSERT_REG(i2, LLDB_INVALID_INDEX32);
 }
 
-TEST_F(DynamicRegisterInfoTest, add_supplementary_register) {
-  // Add a base register
-  uint32_t rax = AddTestRegister("rax", 8);
-
-  // Register numbers
-  uint32_t eax = 1;
-  uint32_t ax = 2;
-  uint32_t al = 3;
-
-  ConstString group{"supplementary registers"};
-  uint32_t value_regs[2] = {rax, LLDB_INVALID_REGNUM};
-  struct RegisterInfo eax_reg {
-"eax", nullptr, 4, LLDB_INVALID_INDEX32, lldb::eEncodingUint,
-lldb::eFormatUnsigned,
-{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, eax,
- eax},
-value_regs, nullptr
-  };
-  info.AddSupplementaryRegister(eax_reg, group);
+class DynamicRegisterInfoRegisterTest : public ::testing::Test {
+protected:
+  std::vector regs;
+
+  uint32_t AddTestRegister(
+  const char *name, const char *group, uint32_t byte_size,
+  std::function adder,
+  std::vector value_regs = {},
+  std::vector invalidate_regs = {}) {
+DynamicRegisterInfo::Register new_reg{
+ConstString(name), ConstString(),
+ConstString(group),byte_size,
+LLDB_INVALID_INDEX32,  lldb::eEncodingUint,
+lldb::eFormatUnsigned, LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM,   LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM,   value_regs,
+invalidate_regs};
+adder(new_reg);
+return regs.size() - 1;
+  }
 
-  struct RegisterInfo ax_reg {
-"ax", nullptr, 2, LLDB_INVALID_INDEX32, lldb::eEncodingUint,
-lldb::eFormatUnsigned,
-{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, ax, ax},
-value_regs, nullptr
-  };
-  info.AddSupplementaryRegister(ax_reg, group);
+  void AssertRegisterInfo(uint32_t reg_num, const char *reg_name,
+  std::vector value_regs = {},
+  std::vector invalidate_regs = {}) {
+EXPECT_GT(regs.size(), reg_num);
+if (regs.size() <= reg_num)
+  return;
 
-  struct RegisterInfo al_reg {
-"al", nullptr, 1, LLDB_INVALID_INDEX32, lldb::eEncodingUint,
-lldb::eFormatUnsigned,
-{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, al, al},
-value_regs, nullptr
-  };
-  info.AddSupplementaryRegister(al_reg, group);
+const DynamicRegisterInfo::Register ® = regs[reg_num];
+ConstString expected_reg_name{reg_name};
+EXPECT_EQ(reg.name, expected_reg_name);
+EXPECT_EQ(reg.value_regs, value_regs);
+EXPECT_EQ(reg.invalidate_regs, invalidate_regs);
+  }
+};
 
-  info.Finalize(lldb_private::ArchSpec());
+#define ASSERT_REG(reg, ...)   \
+  {\
+SCOPED_TRACE("at register " #reg); \
+AssertRegisterInfo(reg, #reg, __VA_ARGS__);\
+  }
+
+TEST_F(DynamicRegisterInfoRegisterTest, addSupplementaryRegister) {
+  // Add a base register
+  uint32_t rax = AddTestRegister(
+  "rax", "group", 8,
+  [this](const DynamicRegisterInfo::Register &r) { regs.push_back(r); });
 
-  ASSERT_REG(rax, 0, {}, {eax, ax, al});
-  ASSERT_REG(eax, 0, {rax}, {rax, ax, al});
-  ASSERT_REG(ax, 0, {rax}, {rax, eax, al});
-  ASSERT_REG(al, 0, {rax}, {rax, eax, ax});
+  // Add supplementary registers
+  auto suppl_adder = [this](const DynamicRegis

[Lldb-commits] [PATCH] D111295: [lldb] [Target] Make addSupplementaryRegister() work on Register vector

2021-10-07 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 377834.
mgorny added a comment.

Remove duplicate `ASSERT_REG`.


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

https://reviews.llvm.org/D111295

Files:
  lldb/include/lldb/Target/DynamicRegisterInfo.h
  lldb/source/Target/DynamicRegisterInfo.cpp
  lldb/unittests/Target/DynamicRegisterInfoTest.cpp

Index: lldb/unittests/Target/DynamicRegisterInfoTest.cpp
===
--- lldb/unittests/Target/DynamicRegisterInfoTest.cpp
+++ lldb/unittests/Target/DynamicRegisterInfoTest.cpp
@@ -12,6 +12,8 @@
 #include "lldb/Target/DynamicRegisterInfo.h"
 #include "lldb/Utility/ArchSpec.h"
 
+#include 
+
 using namespace lldb_private;
 
 static std::vector regs_to_vector(uint32_t *regs) {
@@ -69,9 +71,10 @@
   }
 };
 
-#define ASSERT_REG(reg, ...) { \
-  SCOPED_TRACE("at register " #reg); \
-  AssertRegisterInfo(reg, #reg, __VA_ARGS__); \
+#define ASSERT_REG(reg, ...)   \
+  {\
+SCOPED_TRACE("at register " #reg); \
+AssertRegisterInfo(reg, #reg, __VA_ARGS__);\
   }
 
 TEST_F(DynamicRegisterInfoTest, finalize_regs) {
@@ -124,46 +127,58 @@
   ASSERT_REG(i2, LLDB_INVALID_INDEX32);
 }
 
-TEST_F(DynamicRegisterInfoTest, add_supplementary_register) {
-  // Add a base register
-  uint32_t rax = AddTestRegister("rax", 8);
-
-  // Register numbers
-  uint32_t eax = 1;
-  uint32_t ax = 2;
-  uint32_t al = 3;
-
-  ConstString group{"supplementary registers"};
-  uint32_t value_regs[2] = {rax, LLDB_INVALID_REGNUM};
-  struct RegisterInfo eax_reg {
-"eax", nullptr, 4, LLDB_INVALID_INDEX32, lldb::eEncodingUint,
-lldb::eFormatUnsigned,
-{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, eax,
- eax},
-value_regs, nullptr
-  };
-  info.AddSupplementaryRegister(eax_reg, group);
+class DynamicRegisterInfoRegisterTest : public ::testing::Test {
+protected:
+  std::vector regs;
+
+  uint32_t AddTestRegister(
+  const char *name, const char *group, uint32_t byte_size,
+  std::function adder,
+  std::vector value_regs = {},
+  std::vector invalidate_regs = {}) {
+DynamicRegisterInfo::Register new_reg{
+ConstString(name), ConstString(),
+ConstString(group),byte_size,
+LLDB_INVALID_INDEX32,  lldb::eEncodingUint,
+lldb::eFormatUnsigned, LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM,   LLDB_INVALID_REGNUM,
+LLDB_INVALID_REGNUM,   value_regs,
+invalidate_regs};
+adder(new_reg);
+return regs.size() - 1;
+  }
 
-  struct RegisterInfo ax_reg {
-"ax", nullptr, 2, LLDB_INVALID_INDEX32, lldb::eEncodingUint,
-lldb::eFormatUnsigned,
-{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, ax, ax},
-value_regs, nullptr
-  };
-  info.AddSupplementaryRegister(ax_reg, group);
+  void AssertRegisterInfo(uint32_t reg_num, const char *reg_name,
+  std::vector value_regs = {},
+  std::vector invalidate_regs = {}) {
+EXPECT_GT(regs.size(), reg_num);
+if (regs.size() <= reg_num)
+  return;
 
-  struct RegisterInfo al_reg {
-"al", nullptr, 1, LLDB_INVALID_INDEX32, lldb::eEncodingUint,
-lldb::eFormatUnsigned,
-{LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM, al, al},
-value_regs, nullptr
-  };
-  info.AddSupplementaryRegister(al_reg, group);
+const DynamicRegisterInfo::Register ® = regs[reg_num];
+ConstString expected_reg_name{reg_name};
+EXPECT_EQ(reg.name, expected_reg_name);
+EXPECT_EQ(reg.value_regs, value_regs);
+EXPECT_EQ(reg.invalidate_regs, invalidate_regs);
+  }
+};
 
-  info.Finalize(lldb_private::ArchSpec());
+TEST_F(DynamicRegisterInfoRegisterTest, addSupplementaryRegister) {
+  // Add a base register
+  uint32_t rax = AddTestRegister(
+  "rax", "group", 8,
+  [this](const DynamicRegisterInfo::Register &r) { regs.push_back(r); });
 
-  ASSERT_REG(rax, 0, {}, {eax, ax, al});
-  ASSERT_REG(eax, 0, {rax}, {rax, ax, al});
-  ASSERT_REG(ax, 0, {rax}, {rax, eax, al});
-  ASSERT_REG(al, 0, {rax}, {rax, eax, ax});
+  // Add supplementary registers
+  auto suppl_adder = [this](const DynamicRegisterInfo::Register &r) {
+addSupplementaryRegister(regs, r);
+  };
+  uint32_t eax = AddTestRegister("eax", "supplementary", 4, suppl_adder, {rax});
+  uint32_t ax = AddTestRegister("ax", "supplementary", 2, suppl_adder, {rax});
+  uint32_t al = AddTestRegister("al", "supplementary", 1, suppl_adder, {rax});
+
+  ASSERT_REG(rax, {}, {eax, ax, al});
+  ASSERT_REG(eax, {rax}, {rax, ax, al});
+  ASSERT_REG(ax, {rax}, {rax, eax, al});
+  ASSERT_REG(al, {rax}, {rax, eax, ax});
 }
Index: lldb/source/Target/DynamicRegisterInfo.cpp

[Lldb-commits] [PATCH] D109876: [lldb] [ABI/AArch64] Add pseudo-regs if missing

2021-10-07 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 377835.
mgorny added a comment.

Rebase.


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

https://reviews.llvm.org/D109876

Files:
  lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
  lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py

Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
===
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -380,6 +380,7 @@
 return "".join(reg_data)
 
 def writeRegisters(self, reg_hex):
+reg_data[:] = [reg_hex]
 return "OK"
 
 def haltReason(self):
@@ -429,3 +430,43 @@
["v0 = {0x81 0x82 0x83 0x84 0x85 0x86 0x87 0x88 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90}"])
 self.match("register read v31",
["v31 = {0xa1 0xa2 0xa3 0xa4 0xa5 0xa6 0xa7 0xa8 0xa9 0xaa 0xab 0xac 0xad 0xae 0xaf 0xb0}"])
+
+# test partial registers
+self.match("register read w0",
+   ["w0 = 0x04030201"])
+self.runCmd("register write w0 0xfffefdfc")
+self.match("register read x0",
+   ["x0 = 0x08070605fffefdfc"])
+
+self.match("register read w1",
+   ["w1 = 0x14131211"])
+self.runCmd("register write w1 0xefeeedec")
+self.match("register read x1",
+   ["x1 = 0x18171615efeeedec"])
+
+self.match("register read w30",
+   ["w30 = 0x44434241"])
+self.runCmd("register write w30 0xdfdedddc")
+self.match("register read x30",
+   ["x30 = 0x48474645dfdedddc"])
+
+self.match("register read w31",
+   ["w31 = 0x54535251"])
+self.runCmd("register write w31 0xcfcecdcc")
+self.match("register read x31",
+   ["sp = 0x58575655cfcecdcc"])
+
+# test FPU registers (overlapping with vector registers)
+self.runCmd("register write d0 16")
+self.match("register read v0",
+   ["v0 = {0x00 0x00 0x00 0x00 0x00 0x00 0x30 0x40 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90}"])
+self.runCmd("register write v31 '{0x00 0x00 0x00 0x00 0x00 0x00 0x50 0x40 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff}'")
+self.match("register read d31",
+   ["d31 = 64"])
+
+self.runCmd("register write s0 32")
+self.match("register read v0",
+   ["v0 = {0x00 0x00 0x00 0x42 0x00 0x00 0x30 0x40 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f 0x90}"])
+self.runCmd("register write v31 '{0x00 0x00 0x00 0x43 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff}'")
+self.match("register read s31",
+   ["s31 = 128"])
Index: lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
===
--- lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
+++ lldb/source/Plugins/ABI/AArch64/ABIAArch64.cpp
@@ -71,14 +71,93 @@
   .Default(LLDB_INVALID_REGNUM);
 }
 
+static void addPartialRegister(
+std::vector ®s,
+uint32_t full_reg_index, uint32_t full_reg_size,
+const std::string &partial_reg_name, uint32_t partial_reg_size,
+lldb::Encoding encoding, lldb::Format format, uint32_t &next_regnum_lldb) {
+  if (full_reg_index == LLDB_INVALID_REGNUM ||
+  regs[full_reg_index].byte_size != full_reg_size)
+return;
+
+  lldb_private::DynamicRegisterInfo::Register partial_reg{
+  lldb_private::ConstString(partial_reg_name),
+  lldb_private::ConstString(),
+  lldb_private::ConstString("partial registers"),
+  partial_reg_size,
+  LLDB_INVALID_INDEX32,
+  encoding,
+  format,
+  LLDB_INVALID_REGNUM,
+  LLDB_INVALID_REGNUM,
+  LLDB_INVALID_REGNUM,
+  LLDB_INVALID_REGNUM,
+  {full_reg_index},
+  {}};
+
+  addSupplementaryRegister(regs, partial_reg);
+}
+
 void ABIAArch64::AugmentRegisterInfo(
 std::vector ®s) {
   lldb_private::MCBasedABI::AugmentRegisterInfo(regs);
 
   lldb_private::ConstString sp_string{"sp"};
-  for (lldb_private::DynamicRegisterInfo::Register &info : regs) {
+
+  std::array x_regs{LLDB_INVALID_REGNUM};
+  std::array v_regs{LLDB_INVALID_REGNUM};
+  std::array have_w_regs{false};
+  std::array have_s_regs{false};
+  std::array have_d_regs{false};
+
+  for (auto it : llvm::enumerate(regs)) {
+lldb_private::DynamicRegisterInfo::Register &info = it.value();
 // GDB sends x31 as "sp".  Add the "x31" alt_name for convenience.
 if (info.name == sp_string && !info.alt_name)
   info.alt_name.SetCString("x31");
+
+unsigned int reg_num;
+auto get_reg = [&info, ®_num](const char *prefix) {
+  llvm::StringRef reg_name = info.name.GetStringRef();
+  llvm::StringRef alt_name = info.alt_name.GetStringR

[Lldb-commits] [lldb] ecfab0b - [lldb] [DynamicRegisterInfo] Support iterating over registers()

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

Author: Michał Górny
Date: 2021-10-07T16:07:04+02:00
New Revision: ecfab0b6f581c69b3e3e8b230f97a84f317bbec2

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

LOG: [lldb] [DynamicRegisterInfo] Support iterating over registers()

Add DynamicRegisterInfo::registers() method that returns
llvm::iterator_range<> over RegisterInfos.  This is a convenient
replacement for GetNumRegisters() + GetRegisterInfoAtIndex().

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

Added: 


Modified: 
lldb/include/lldb/Target/DynamicRegisterInfo.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/DynamicRegisterInfo.h 
b/lldb/include/lldb/Target/DynamicRegisterInfo.h
index 5cbafe000e0b0..5fd0389e3e82c 100644
--- a/lldb/include/lldb/Target/DynamicRegisterInfo.h
+++ b/lldb/include/lldb/Target/DynamicRegisterInfo.h
@@ -77,9 +77,13 @@ class DynamicRegisterInfo {
   const lldb_private::RegisterInfo *
   GetRegisterInfo(llvm::StringRef reg_name) const;
 
+  typedef std::vector reg_collection;
+  llvm::iterator_range registers() const {
+return llvm::iterator_range(m_regs);
+  }
+
 protected:
   // Classes that inherit from DynamicRegisterInfo can see and modify these
-  typedef std::vector reg_collection;
   typedef std::vector set_collection;
   typedef std::vector reg_num_collection;
   typedef std::vector set_reg_num_collection;

diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
index b80498069f164..f0225d0ad5609 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -203,16 +203,11 @@ bool GDBRemoteRegisterContext::ReadRegisterBytes(const 
RegisterInfo *reg_info) {
   SetAllRegisterValid(true);
   return true;
 } else if (buffer_sp->GetByteSize() > 0) {
-  const int regcount = m_reg_info_sp->GetNumRegisters();
-  for (int i = 0; i < regcount; i++) {
-struct RegisterInfo *reginfo =
-m_reg_info_sp->GetRegisterInfoAtIndex(i);
-if (reginfo->byte_offset + reginfo->byte_size <=
-buffer_sp->GetByteSize()) {
-  m_reg_valid[i] = true;
-} else {
-  m_reg_valid[i] = false;
-}
+  for (auto x : llvm::enumerate(m_reg_info_sp->registers())) {
+const struct RegisterInfo ®info = x.value();
+m_reg_valid[x.index()] =
+(reginfo.byte_offset + reginfo.byte_size <=
+ buffer_sp->GetByteSize());
   }
 
   m_gpacket_cached = true;



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


[Lldb-commits] [PATCH] D111136: [lldb] [DynamicRegisterInfo] Support iterating over registers()

2021-10-07 Thread Michał Górny via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGecfab0b6f581: [lldb] [DynamicRegisterInfo] Support iterating 
over registers() (authored by mgorny).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D36

Files:
  lldb/include/lldb/Target/DynamicRegisterInfo.h
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp


Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -203,16 +203,11 @@
   SetAllRegisterValid(true);
   return true;
 } else if (buffer_sp->GetByteSize() > 0) {
-  const int regcount = m_reg_info_sp->GetNumRegisters();
-  for (int i = 0; i < regcount; i++) {
-struct RegisterInfo *reginfo =
-m_reg_info_sp->GetRegisterInfoAtIndex(i);
-if (reginfo->byte_offset + reginfo->byte_size <=
-buffer_sp->GetByteSize()) {
-  m_reg_valid[i] = true;
-} else {
-  m_reg_valid[i] = false;
-}
+  for (auto x : llvm::enumerate(m_reg_info_sp->registers())) {
+const struct RegisterInfo ®info = x.value();
+m_reg_valid[x.index()] =
+(reginfo.byte_offset + reginfo.byte_size <=
+ buffer_sp->GetByteSize());
   }
 
   m_gpacket_cached = true;
Index: lldb/include/lldb/Target/DynamicRegisterInfo.h
===
--- lldb/include/lldb/Target/DynamicRegisterInfo.h
+++ lldb/include/lldb/Target/DynamicRegisterInfo.h
@@ -77,9 +77,13 @@
   const lldb_private::RegisterInfo *
   GetRegisterInfo(llvm::StringRef reg_name) const;
 
+  typedef std::vector reg_collection;
+  llvm::iterator_range registers() const {
+return llvm::iterator_range(m_regs);
+  }
+
 protected:
   // Classes that inherit from DynamicRegisterInfo can see and modify these
-  typedef std::vector reg_collection;
   typedef std::vector set_collection;
   typedef std::vector reg_num_collection;
   typedef std::vector set_reg_num_collection;


Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.cpp
@@ -203,16 +203,11 @@
   SetAllRegisterValid(true);
   return true;
 } else if (buffer_sp->GetByteSize() > 0) {
-  const int regcount = m_reg_info_sp->GetNumRegisters();
-  for (int i = 0; i < regcount; i++) {
-struct RegisterInfo *reginfo =
-m_reg_info_sp->GetRegisterInfoAtIndex(i);
-if (reginfo->byte_offset + reginfo->byte_size <=
-buffer_sp->GetByteSize()) {
-  m_reg_valid[i] = true;
-} else {
-  m_reg_valid[i] = false;
-}
+  for (auto x : llvm::enumerate(m_reg_info_sp->registers())) {
+const struct RegisterInfo ®info = x.value();
+m_reg_valid[x.index()] =
+(reginfo.byte_offset + reginfo.byte_size <=
+ buffer_sp->GetByteSize());
   }
 
   m_gpacket_cached = true;
Index: lldb/include/lldb/Target/DynamicRegisterInfo.h
===
--- lldb/include/lldb/Target/DynamicRegisterInfo.h
+++ lldb/include/lldb/Target/DynamicRegisterInfo.h
@@ -77,9 +77,13 @@
   const lldb_private::RegisterInfo *
   GetRegisterInfo(llvm::StringRef reg_name) const;
 
+  typedef std::vector reg_collection;
+  llvm::iterator_range registers() const {
+return llvm::iterator_range(m_regs);
+  }
+
 protected:
   // Classes that inherit from DynamicRegisterInfo can see and modify these
-  typedef std::vector reg_collection;
   typedef std::vector set_collection;
   typedef std::vector reg_num_collection;
   typedef std::vector set_reg_num_collection;
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D111314: [lldb] [ConnectionFileDescriptorPosix] Use a single NativeFile

2021-10-07 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, teemperor, krytarowski, emaste.
mgorny requested review of this revision.

Replace separate read and write NativeFile instances with a single
instance shared for reading and writing.  There is no clear indication
why two instances were used in the first place, and replacing them
with just one does not seem to cause any regressions in tests or manual
'process connect file://...'.


https://reviews.llvm.org/D111314

Files:
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp


Index: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
===
--- lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -85,9 +85,8 @@
 : Connection(), m_pipe(), m_mutex(), m_shutting_down(false),
   m_waiting_for_accept(false), m_child_processes_inherit(false) {
   m_write_sp =
-  std::make_shared(fd, File::eOpenOptionWriteOnly, owns_fd);
-  m_read_sp =
-  std::make_shared(fd, File::eOpenOptionReadOnly, false);
+  std::make_shared(fd, File::eOpenOptionReadWrite, owns_fd);
+  m_read_sp = m_write_sp;
 
   Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION |
   LIBLLDB_LOG_OBJECT));
@@ -219,9 +218,8 @@
 m_write_sp = m_read_sp;
   } else {
 m_read_sp = std::make_shared(
-fd, File::eOpenOptionReadOnly, false);
-m_write_sp = std::make_shared(
-fd, File::eOpenOptionWriteOnly, false);
+fd, File::eOpenOptionReadWrite, false);
+m_write_sp = m_read_sp;
   }
   m_uri = std::string(*addr);
   return eConnectionStatusSuccess;
@@ -259,9 +257,8 @@
 }
   }
   m_read_sp =
-  std::make_shared(fd, File::eOpenOptionReadOnly, true);
-  m_write_sp =
-  std::make_shared(fd, File::eOpenOptionWriteOnly, false);
+  std::make_shared(fd, File::eOpenOptionReadWrite, true);
+  m_write_sp = m_read_sp;
   return eConnectionStatusSuccess;
 }
 #endif


Index: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
===
--- lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -85,9 +85,8 @@
 : Connection(), m_pipe(), m_mutex(), m_shutting_down(false),
   m_waiting_for_accept(false), m_child_processes_inherit(false) {
   m_write_sp =
-  std::make_shared(fd, File::eOpenOptionWriteOnly, owns_fd);
-  m_read_sp =
-  std::make_shared(fd, File::eOpenOptionReadOnly, false);
+  std::make_shared(fd, File::eOpenOptionReadWrite, owns_fd);
+  m_read_sp = m_write_sp;
 
   Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_CONNECTION |
   LIBLLDB_LOG_OBJECT));
@@ -219,9 +218,8 @@
 m_write_sp = m_read_sp;
   } else {
 m_read_sp = std::make_shared(
-fd, File::eOpenOptionReadOnly, false);
-m_write_sp = std::make_shared(
-fd, File::eOpenOptionWriteOnly, false);
+fd, File::eOpenOptionReadWrite, false);
+m_write_sp = m_read_sp;
   }
   m_uri = std::string(*addr);
   return eConnectionStatusSuccess;
@@ -259,9 +257,8 @@
 }
   }
   m_read_sp =
-  std::make_shared(fd, File::eOpenOptionReadOnly, true);
-  m_write_sp =
-  std::make_shared(fd, File::eOpenOptionWriteOnly, false);
+  std::make_shared(fd, File::eOpenOptionReadWrite, true);
+  m_write_sp = m_read_sp;
   return eConnectionStatusSuccess;
 }
 #endif
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 80e3936 - [lldb, mlir] Migrate from getNumArgOperands and arg_operands (NFC)

2021-10-07 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2021-10-07T08:29:42-07:00
New Revision: 80e39366ee403ac420f2087883550398e5fbf968

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

LOG: [lldb, mlir] Migrate from getNumArgOperands and arg_operands (NFC)

Note that getNumArgOperands and arg_operands are considered legacy
names.  See llvm/include/llvm/IR/InstrTypes.h for details.

Added: 


Modified: 
lldb/source/Expression/IRInterpreter.cpp
lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp

Removed: 




diff  --git a/lldb/source/Expression/IRInterpreter.cpp 
b/lldb/source/Expression/IRInterpreter.cpp
index 788520d1f32bf..9b2af56dfc8a2 100644
--- a/lldb/source/Expression/IRInterpreter.cpp
+++ b/lldb/source/Expression/IRInterpreter.cpp
@@ -1398,7 +1398,7 @@ bool IRInterpreter::Interpret(llvm::Module &module, 
llvm::Function &function,
   }
 
   // Find number of arguments
-  const int numArgs = call_inst->getNumArgOperands();
+  const int numArgs = call_inst->arg_size();
 
   // We work with a fixed array of 16 arguments which is our upper limit
   static lldb_private::ABI::CallArgument rawArgs[16];

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
index 5655d548ee344..f80dc2b144672 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
@@ -1303,7 +1303,7 @@ bool IRForTarget::MaybeHandleCallArguments(CallInst *Old) 
{
 
   LLDB_LOG(log, "MaybeHandleCallArguments({0})", PrintValue(Old));
 
-  for (unsigned op_index = 0, num_ops = Old->getNumArgOperands();
+  for (unsigned op_index = 0, num_ops = Old->arg_size();
op_index < num_ops; ++op_index)
 // conservatively believe that this is a store
 if (!MaybeHandleVariable(Old->getArgOperand(op_index))) {

diff  --git a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp 
b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
index 199a8c49aca8c..ab37d60b6dbee 100644
--- a/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
+++ b/mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp
@@ -653,7 +653,7 @@ LogicalResult 
Importer::processInstruction(llvm::Instruction *inst) {
 llvm::CallInst *ci = cast(inst);
 SmallVector ops;
 ops.reserve(inst->getNumOperands());
-for (auto &op : ci->arg_operands()) {
+for (auto &op : ci->args()) {
   Value arg = processValue(op.get());
   if (!arg)
 return failure();
@@ -705,7 +705,7 @@ LogicalResult 
Importer::processInstruction(llvm::Instruction *inst) {
 
 SmallVector ops;
 ops.reserve(inst->getNumOperands() + 1);
-for (auto &op : ii->arg_operands())
+for (auto &op : ii->args())
   ops.push_back(processValue(op.get()));
 
 SmallVector normalArgs, unwindArgs;



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


[Lldb-commits] [PATCH] D108953: [lldb/Plugins] Add memory region support in ScriptedProcess

2021-10-07 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




Comment at: lldb/examples/python/scripted_process/my_scripted_process.py:126
 def get_register_context(self) -> str:
-return struct.pack(
-'21Q', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 
17, 18, 19, 20, 21)
+return struct.pack(f"{len(self.registers)}Q", *self.registers.values())
 

Aren't format strings only available in Python 3?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108953

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


[Lldb-commits] [PATCH] D111321: [lldb] [ConnectionFileDescriptorPosix] Refactor scheme matching

2021-10-07 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, teemperor, krytarowski, emaste.
mgorny requested review of this revision.

Move the POSIX-specific fd:// and file:// scheme handling into
separate methods.  Replace the custom GetURLAddress() matching with
splitting into scheme and path, and matching scheme via
llvm::StringSwitch.


https://reviews.llvm.org/D111321

Files:
  lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp

Index: lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
===
--- lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
+++ lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
@@ -120,9 +120,9 @@
 m_device_id = std::string(host);
 
   m_socket_namespace.reset();
-  if (scheme == ConnectionFileDescriptor::UNIX_CONNECT_SCHEME)
+  if (scheme == "unix-connect")
 m_socket_namespace = AdbClient::UnixSocketNamespaceFileSystem;
-  else if (scheme == ConnectionFileDescriptor::UNIX_ABSTRACT_CONNECT_SCHEME)
+  else if (scheme == "unix-abstract-connect")
 m_socket_namespace = AdbClient::UnixSocketNamespaceAbstract;
 
   std::string connect_url;
Index: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
===
--- lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -50,27 +50,6 @@
 using namespace lldb;
 using namespace lldb_private;
 
-const char *ConnectionFileDescriptor::LISTEN_SCHEME = "listen";
-const char *ConnectionFileDescriptor::ACCEPT_SCHEME = "accept";
-const char *ConnectionFileDescriptor::UNIX_ACCEPT_SCHEME = "unix-accept";
-const char *ConnectionFileDescriptor::CONNECT_SCHEME = "connect";
-const char *ConnectionFileDescriptor::TCP_CONNECT_SCHEME = "tcp-connect";
-const char *ConnectionFileDescriptor::UDP_SCHEME = "udp";
-const char *ConnectionFileDescriptor::UNIX_CONNECT_SCHEME = "unix-connect";
-const char *ConnectionFileDescriptor::UNIX_ABSTRACT_CONNECT_SCHEME =
-"unix-abstract-connect";
-const char *ConnectionFileDescriptor::FD_SCHEME = "fd";
-const char *ConnectionFileDescriptor::FILE_SCHEME = "file";
-
-static llvm::Optional GetURLAddress(llvm::StringRef url,
- llvm::StringRef scheme) {
-  if (!url.consume_front(scheme))
-return llvm::None;
-  if (!url.consume_front("://"))
-return llvm::None;
-  return url;
-}
-
 ConnectionFileDescriptor::ConnectionFileDescriptor(bool child_processes_inherit)
 : Connection(), m_pipe(), m_mutex(), m_shutting_down(false),
 
@@ -155,113 +134,33 @@
   OpenCommandPipe();
 
   if (!path.empty()) {
-llvm::Optional addr;
-if ((addr = GetURLAddress(path, LISTEN_SCHEME))) {
-  // listen://HOST:PORT
-  return SocketListenAndAccept(*addr, error_ptr);
-} else if ((addr = GetURLAddress(path, ACCEPT_SCHEME))) {
-  // unix://SOCKNAME
-  return NamedSocketAccept(*addr, error_ptr);
-} else if ((addr = GetURLAddress(path, UNIX_ACCEPT_SCHEME))) {
-  // unix://SOCKNAME
-  return NamedSocketAccept(*addr, error_ptr);
-} else if ((addr = GetURLAddress(path, CONNECT_SCHEME))) {
-  return ConnectTCP(*addr, error_ptr);
-} else if ((addr = GetURLAddress(path, TCP_CONNECT_SCHEME))) {
-  return ConnectTCP(*addr, error_ptr);
-} else if ((addr = GetURLAddress(path, UDP_SCHEME))) {
-  return ConnectUDP(*addr, error_ptr);
-} else if ((addr = GetURLAddress(path, UNIX_CONNECT_SCHEME))) {
-  // unix-connect://SOCKNAME
-  return NamedSocketConnect(*addr, error_ptr);
-} else if ((addr = GetURLAddress(path, UNIX_ABSTRACT_CONNECT_SCHEME))) {
-  // unix-abstract-connect://SOCKNAME
-  return UnixAbstractSocketConnect(*addr, error_ptr);
-}
+llvm::StringRef scheme;
+std::tie(scheme, path) = path.split("://");
+
+if (!path.empty()) {
+  auto method =
+  llvm::StringSwitch>(scheme)
+  .Case("listen", &ConnectionFileDescriptor::SocketListenAndAccept)
+  .Cases("accept", "unix-accept",
+ &ConnectionFileDescriptor::NamedSocketAccept)
+  .Cases("connect", "tcp-connect",
+ &ConnectionFileDescriptor::ConnectTCP)
+  .Case("udp", &ConnectionFileDescriptor::ConnectUDP)
+  .Case("unix-connect",
+&ConnectionFileDescriptor::NamedSocketConnect)
+  .Case("unix-abstract-connect",
+&ConnectionFileDescriptor::UnixAbstractSocketConnect)
 #if LLDB_ENABLE_POSIX
-else if ((addr = GetURLAddress(path, FD_SCHEME))) {
-  // Just passing a native file descriptor within this current process that
-  // is already opened (possibly from a service or other source)

[Lldb-commits] [lldb] 5ecdb77 - [lldb] Mark abort signal test unsupported on AArch64 Linux

2021-10-07 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2021-10-07T16:09:47Z
New Revision: 5ecdb77fc5e71daf994d39840fbe753f46aeca43

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

LOG: [lldb] Mark abort signal test unsupported on AArch64 Linux

This has started failing since we moved our bots to Focal.
For unknown reasons the abort_caller stack is missing when
we check from the handler breakpoint.

Mark unsupported while I investigate.

Added: 


Modified: 
lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py 
b/lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
index 5f3eb31c83ae..013ea8859b45 100644
--- a/lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
+++ b/lldb/test/API/functionalities/signal/handle-abrt/TestHandleAbort.py
@@ -16,6 +16,8 @@ class HandleAbortTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
 @skipIfWindows  # signals do not exist on Windows
+# Fails on Ubuntu Focal
+@skipIf(archs=["aarch64"], oslist=["linux"])
 @expectedFailureNetBSD
 def test_inferior_handle_sigabrt(self):
 """Inferior calls abort() and handles the resultant SIGABRT.



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


[Lldb-commits] [lldb] 3d7d543 - [lldb] Fix a "missing field" warning

2021-10-07 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2021-10-07T10:25:05-07:00
New Revision: 3d7d5437433c16fd4a9a3674d3752c246961d70e

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

LOG: [lldb] Fix a "missing field" warning

This patch fixes:

  llvm-project/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp:204:6:
  error: missing field 'invalidate_regs' initializer
  [-Werror,-Wmissing-field-initializers]

Added: 


Modified: 
lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp 
b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
index d2f53f71e431a..579eb0809ffd3 100644
--- a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
+++ b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc.cpp
@@ -200,6 +200,7 @@ static const RegisterInfo g_register_infos[] = {
  eFormatHex,
  {dwarf_cfa, dwarf_cfa, LLDB_INVALID_REGNUM, LLDB_INVALID_REGNUM},
  nullptr,
+ nullptr,
  }};
 
 static const uint32_t k_num_register_infos =



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


[Lldb-commits] [PATCH] D110298: Add "command multiword add" and the ability to add script commands into a user multiword hierarchy

2021-10-07 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added a comment.

A few more nits as I was reading through the code, but this generally LGTM.




Comment at: lldb/source/Commands/CommandCompletions.cpp:811-813
+  sort(to_delete.begin(), to_delete.end(), std::greater());
+  for (size_t idx : to_delete)
+args.DeleteArgumentAtIndex(idx);

jingham wrote:
> JDevlieghere wrote:
> > I'm surprised this works. Don't the indexes shift when one's deleted? I 
> > assumed that's why you're sorting them. 
> Why wouldn't it?
> 
> The delete starts with the greatest index, so each time you delete an entry 
> it shuffles the ones above it down, but it doesn't reshuffle the ones below 
> it.  Since all the remaining indices are lower than the one you just deleted, 
> they are all still pointing to the elements you intend to remove.
Got it, I got the direction wrong.



Comment at: lldb/source/Commands/CommandObjectCommands.cpp:2028
+if (num_args == 0) {
+  result.AppendError("No command was specified.");
+  return false;

This method still has some inconsistencies in capitalization. 



Comment at: lldb/source/Commands/CommandObjectMultiword.cpp:34-35
+
+  CommandObject::CommandMap::iterator pos;
+  pos = m_subcommand_dict.find(std::string(sub_cmd));
+  if (pos == m_subcommand_dict.end())





Comment at: lldb/source/Commands/CommandObjectMultiword.cpp:54-67
   CommandObject::CommandMap::iterator pos;
 
-  if (!m_subcommand_dict.empty()) {
+  StringList local_matches;
+  if (matches == nullptr)
+matches = &local_matches;
+  int num_matches =
+  AddNamesMatchingPartialString(m_subcommand_dict, sub_cmd, *matches);





Comment at: lldb/source/Commands/CommandObjectMultiword.cpp:112-115
+  CommandMap::iterator pos;
+  std::string str_name(name);
+
+  pos = m_subcommand_dict.find(str_name);





Comment at: lldb/source/Commands/CommandObjectMultiword.cpp:121-129
+  const char *error_str = nullptr;
+  if (!can_replace)
+error_str = "sub-command already exists";
+  if (!(*pos).second->IsUserCommand())
+error_str = "can't replace a builtin subcommand";
+
+  if (error_str) {

This inline diff looks more confusing than anything, but basically I just 
switched the errors around (instead of the current fall-through) and return the 
error immediately. 



Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:1259-1262
+  StringList *matches_ptr = matches;
+  StringList tmp_list;
+  if (!matches_ptr)
+matches_ptr = &tmp_list;





Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:1369-1370
+bool CommandInterpreter::RemoveUserMultiword(llvm::StringRef multi_name) {
+  CommandObject::CommandMap::iterator pos =
+  m_user_mw_dict.find(std::string(multi_name));
+  if (pos != m_user_mw_dict.end()) {




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110298

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


[Lldb-commits] [PATCH] D111321: [lldb] [ConnectionFileDescriptorPosix] Refactor scheme matching

2021-10-07 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 377948.
mgorny added a comment.

Rebase to match the original termios code without other of my patches.


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

https://reviews.llvm.org/D111321

Files:
  lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp

Index: lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
===
--- lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
+++ lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
@@ -120,9 +120,9 @@
 m_device_id = std::string(host);
 
   m_socket_namespace.reset();
-  if (scheme == ConnectionFileDescriptor::UNIX_CONNECT_SCHEME)
+  if (scheme == "unix-connect")
 m_socket_namespace = AdbClient::UnixSocketNamespaceFileSystem;
-  else if (scheme == ConnectionFileDescriptor::UNIX_ABSTRACT_CONNECT_SCHEME)
+  else if (scheme == "unix-abstract-connect")
 m_socket_namespace = AdbClient::UnixSocketNamespaceAbstract;
 
   std::string connect_url;
Index: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
===
--- lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -50,27 +50,6 @@
 using namespace lldb;
 using namespace lldb_private;
 
-const char *ConnectionFileDescriptor::LISTEN_SCHEME = "listen";
-const char *ConnectionFileDescriptor::ACCEPT_SCHEME = "accept";
-const char *ConnectionFileDescriptor::UNIX_ACCEPT_SCHEME = "unix-accept";
-const char *ConnectionFileDescriptor::CONNECT_SCHEME = "connect";
-const char *ConnectionFileDescriptor::TCP_CONNECT_SCHEME = "tcp-connect";
-const char *ConnectionFileDescriptor::UDP_SCHEME = "udp";
-const char *ConnectionFileDescriptor::UNIX_CONNECT_SCHEME = "unix-connect";
-const char *ConnectionFileDescriptor::UNIX_ABSTRACT_CONNECT_SCHEME =
-"unix-abstract-connect";
-const char *ConnectionFileDescriptor::FD_SCHEME = "fd";
-const char *ConnectionFileDescriptor::FILE_SCHEME = "file";
-
-static llvm::Optional GetURLAddress(llvm::StringRef url,
- llvm::StringRef scheme) {
-  if (!url.consume_front(scheme))
-return llvm::None;
-  if (!url.consume_front("://"))
-return llvm::None;
-  return url;
-}
-
 ConnectionFileDescriptor::ConnectionFileDescriptor(bool child_processes_inherit)
 : Connection(), m_pipe(), m_mutex(), m_shutting_down(false),
 
@@ -155,125 +134,33 @@
   OpenCommandPipe();
 
   if (!path.empty()) {
-llvm::Optional addr;
-if ((addr = GetURLAddress(path, LISTEN_SCHEME))) {
-  // listen://HOST:PORT
-  return SocketListenAndAccept(*addr, error_ptr);
-} else if ((addr = GetURLAddress(path, ACCEPT_SCHEME))) {
-  // unix://SOCKNAME
-  return NamedSocketAccept(*addr, error_ptr);
-} else if ((addr = GetURLAddress(path, UNIX_ACCEPT_SCHEME))) {
-  // unix://SOCKNAME
-  return NamedSocketAccept(*addr, error_ptr);
-} else if ((addr = GetURLAddress(path, CONNECT_SCHEME))) {
-  return ConnectTCP(*addr, error_ptr);
-} else if ((addr = GetURLAddress(path, TCP_CONNECT_SCHEME))) {
-  return ConnectTCP(*addr, error_ptr);
-} else if ((addr = GetURLAddress(path, UDP_SCHEME))) {
-  return ConnectUDP(*addr, error_ptr);
-} else if ((addr = GetURLAddress(path, UNIX_CONNECT_SCHEME))) {
-  // unix-connect://SOCKNAME
-  return NamedSocketConnect(*addr, error_ptr);
-} else if ((addr = GetURLAddress(path, UNIX_ABSTRACT_CONNECT_SCHEME))) {
-  // unix-abstract-connect://SOCKNAME
-  return UnixAbstractSocketConnect(*addr, error_ptr);
-}
+llvm::StringRef scheme;
+std::tie(scheme, path) = path.split("://");
+
+if (!path.empty()) {
+  auto method =
+  llvm::StringSwitch>(scheme)
+  .Case("listen", &ConnectionFileDescriptor::SocketListenAndAccept)
+  .Cases("accept", "unix-accept",
+ &ConnectionFileDescriptor::NamedSocketAccept)
+  .Cases("connect", "tcp-connect",
+ &ConnectionFileDescriptor::ConnectTCP)
+  .Case("udp", &ConnectionFileDescriptor::ConnectUDP)
+  .Case("unix-connect",
+&ConnectionFileDescriptor::NamedSocketConnect)
+  .Case("unix-abstract-connect",
+&ConnectionFileDescriptor::UnixAbstractSocketConnect)
 #if LLDB_ENABLE_POSIX
-else if ((addr = GetURLAddress(path, FD_SCHEME))) {
-  // Just passing a native file descriptor within this current process that
-  // is already opened (possibly from a service or other source).
-  int fd = -1;
-
-  if (!addr->getAsInteger(0, fd)) {
-// We have what looks to be a valid file descriptor, but we sh

[Lldb-commits] [PATCH] D111030: [lldb] [Host] Add setters for common teletype properties to Terminal

2021-10-07 Thread Michał Górny via Phabricator via lldb-commits
mgorny updated this revision to Diff 377949.
mgorny added a comment.

Remove the changes to ConnectionFileDescriptorPosix from this patch. Now it's 
purely new Terminal API.


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

https://reviews.llvm.org/D111030

Files:
  lldb/include/lldb/Host/Terminal.h
  lldb/source/Host/common/Terminal.cpp
  lldb/unittests/Host/posix/TerminalTest.cpp

Index: lldb/unittests/Host/posix/TerminalTest.cpp
===
--- lldb/unittests/Host/posix/TerminalTest.cpp
+++ lldb/unittests/Host/posix/TerminalTest.cpp
@@ -68,6 +68,132 @@
   EXPECT_EQ(terminfo.c_lflag & ICANON, 0U);
 }
 
+TEST_F(TerminalTest, SetRaw) {
+  struct termios terminfo;
+  Terminal term{m_pty.GetPrimaryFileDescriptor()};
+
+  ASSERT_EQ(term.SetRaw(), true);
+  ASSERT_EQ(tcgetattr(m_pty.GetPrimaryFileDescriptor(), &terminfo), 0);
+  // NB: cfmakeraw() on glibc disables IGNBRK, on FreeBSD sets it
+  EXPECT_EQ(terminfo.c_iflag &
+(BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON),
+0U);
+  EXPECT_EQ(terminfo.c_oflag & OPOST, 0U);
+  EXPECT_EQ(terminfo.c_lflag & (ICANON | ECHO | ISIG | IEXTEN), 0U);
+  EXPECT_EQ(terminfo.c_cflag & (CSIZE | PARENB), 0U | CS8);
+  EXPECT_EQ(terminfo.c_cc[VMIN], 1);
+  EXPECT_EQ(terminfo.c_cc[VTIME], 0);
+}
+
+TEST_F(TerminalTest, SetBaudRate) {
+  struct termios terminfo;
+  Terminal term{m_pty.GetPrimaryFileDescriptor()};
+
+  ASSERT_EQ(term.SetBaudRate(38400), true);
+  ASSERT_EQ(tcgetattr(m_pty.GetPrimaryFileDescriptor(), &terminfo), 0);
+  EXPECT_EQ(cfgetispeed(&terminfo), static_cast(B38400));
+  EXPECT_EQ(cfgetospeed(&terminfo), static_cast(B38400));
+
+  ASSERT_EQ(term.SetBaudRate(115200), true);
+  ASSERT_EQ(tcgetattr(m_pty.GetPrimaryFileDescriptor(), &terminfo), 0);
+  EXPECT_EQ(cfgetispeed(&terminfo), static_cast(B115200));
+  EXPECT_EQ(cfgetospeed(&terminfo), static_cast(B115200));
+
+  // uncommon value
+#if defined(B153600)
+  ASSERT_EQ(term.SetBaudRate(153600), true);
+  ASSERT_EQ(tcgetattr(m_pty.GetPrimaryFileDescriptor(), &terminfo), 0);
+  EXPECT_EQ(cfgetispeed(&terminfo), static_cast(B153600));
+  EXPECT_EQ(cfgetospeed(&terminfo), static_cast(B153600));
+#else
+  EXPECT_EQ(term.SetBaudRate(153600), false);
+#endif
+}
+
+TEST_F(TerminalTest, SetStopBits) {
+  struct termios terminfo;
+  Terminal term{m_pty.GetPrimaryFileDescriptor()};
+
+  ASSERT_EQ(term.SetStopBits(1), true);
+  ASSERT_EQ(tcgetattr(m_pty.GetPrimaryFileDescriptor(), &terminfo), 0);
+  EXPECT_EQ(terminfo.c_cflag & CSTOPB, 0U);
+
+  ASSERT_EQ(term.SetStopBits(2), true);
+  ASSERT_EQ(tcgetattr(m_pty.GetPrimaryFileDescriptor(), &terminfo), 0);
+  EXPECT_NE(terminfo.c_cflag & CSTOPB, 0U);
+
+  ASSERT_EQ(term.SetStopBits(0), false);
+  ASSERT_EQ(term.SetStopBits(3), false);
+}
+
+TEST_F(TerminalTest, SetParity) {
+  struct termios terminfo;
+  Terminal term{m_pty.GetPrimaryFileDescriptor()};
+
+  ASSERT_EQ(term.SetParity(TerminalParity::No), true);
+  ASSERT_EQ(tcgetattr(m_pty.GetPrimaryFileDescriptor(), &terminfo), 0);
+  EXPECT_EQ(terminfo.c_cflag & PARENB, 0U);
+
+  ASSERT_EQ(term.SetParity(TerminalParity::Even), true);
+  ASSERT_EQ(tcgetattr(m_pty.GetPrimaryFileDescriptor(), &terminfo), 0);
+#if !defined(__linux__) // Linux pty devices strip PARENB
+  EXPECT_NE(terminfo.c_cflag & PARENB, 0U);
+#endif
+  EXPECT_EQ(terminfo.c_cflag & PARODD, 0U);
+#if defined(CMSPAR)
+  EXPECT_EQ(terminfo.c_cflag & CMSPAR, 0U);
+#endif
+
+  ASSERT_EQ(term.SetParity(TerminalParity::Odd), true);
+  ASSERT_EQ(tcgetattr(m_pty.GetPrimaryFileDescriptor(), &terminfo), 0);
+#if !defined(__linux__) // Linux pty devices strip PARENB
+  EXPECT_NE(terminfo.c_cflag & PARENB, 0U);
+#endif
+  EXPECT_NE(terminfo.c_cflag & PARODD, 0U);
+#if defined(CMSPAR)
+  EXPECT_EQ(terminfo.c_cflag & CMSPAR, 0U);
+#endif
+
+#if defined(CMSPAR)
+  ASSERT_EQ(term.SetParity(TerminalParity::Space), true);
+  ASSERT_EQ(tcgetattr(m_pty.GetPrimaryFileDescriptor(), &terminfo), 0);
+#if !defined(__linux__) // Linux pty devices strip PARENB
+  EXPECT_NE(terminfo.c_cflag & PARENB, 0U);
+#endif
+  EXPECT_EQ(terminfo.c_cflag & PARODD, 0U);
+  EXPECT_NE(terminfo.c_cflag & CMSPAR, 0U);
+
+  ASSERT_EQ(term.SetParity(TerminalParity::Mark), true);
+  ASSERT_EQ(tcgetattr(m_pty.GetPrimaryFileDescriptor(), &terminfo), 0);
+#if !defined(__linux__) // Linux pty devices strip PARENB
+  EXPECT_NE(terminfo.c_cflag & PARENB, 0U);
+#endif
+  EXPECT_NE(terminfo.c_cflag & PARODD, 0U);
+  EXPECT_NE(terminfo.c_cflag & CMSPAR, 0U);
+#else
+  EXPECT_EQ(term.SetParity(TerminalParity::Space), false);
+  EXPECT_EQ(term.SetParity(TerminalParity::Mark), false);
+#endif
+}
+
+TEST_F(TerminalTest, SetHardwareFlowControl) {
+  struct termios terminfo;
+  Terminal term{m_pty.GetPrimaryFileDescriptor()};
+
+#if defined(CRTSCTS)
+  ASSERT_EQ(term.SetHardwareFlowControl(true), true);
+  ASSERT_EQ(tcgetattr(m_pty.GetPrimaryFileDescriptor(), &terminfo), 0);
+  EXPECT_NE(terminfo.c_cflag & CR

[Lldb-commits] [PATCH] D110997: [lldb] Restore tty attributes on disconnect

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

If at all, this will be part of the new serial port API.


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

https://reviews.llvm.org/D110997

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


[Lldb-commits] [PATCH] D111339: [lldb] Parse and display reporting errors from JSON crashlogs

2021-10-07 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: jingham, aprantl.
JDevlieghere requested review of this revision.

JSON crashlogs have an optional field named `reportNotes` that contains any 
potential errors encountered by the crash reporter when generating the 
crashlog. Parse and display them in LLDB.


https://reviews.llvm.org/D111339

Files:
  lldb/examples/python/crashlog.py
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test


Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
@@ -13,3 +13,5 @@
 # CHECK: [  1] {{.*}}out`bar + 8 at test.c
 # CHECK: [  2] {{.*}}out`main + 19 at test.c
 # CHECK: rbp = 0x7ffeec22a530
+# CHECK: invalid foo
+# CHECK: invalid bar
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
@@ -170,5 +170,9 @@
   "threadTriggered" : {
 "queue" : "com.apple.main-thread"
   }
-}
+},
+  "reportNotes" : [
+  "invalid foo",
+  "invalid bar"
+]
 }
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -330,6 +330,7 @@
 self.threads = list()
 self.backtraces = list()  # For application specific backtraces
 self.idents = list()  # A list of the required identifiers for doing 
all stack backtraces
+self.errors = list()
 self.crashed_thread_idx = -1
 self.version = -1
 self.target = None
@@ -433,6 +434,7 @@
 self.parse_process_info(self.data)
 self.parse_images(self.data['usedImages'])
 self.parse_threads(self.data['threads'])
+self.parse_errors(self.data)
 thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
 reason = self.parse_crash_reason(self.data['exception'])
 if thread.reason:
@@ -523,6 +525,10 @@
pass
 return registers
 
+def parse_errors(self, json_data):
+   if 'reportNotes' in json_data:
+  self.crashlog.errors = json_data['reportNotes']
+
 
 class CrashLogParseMode:
 NORMAL = 0
@@ -1062,6 +1068,11 @@
 thread.dump_symbolicated(crash_log, options)
 print()
 
+if crash_log.errors:
+print("Errors:")
+for error in crash_log.errors:
+print(error)
+
 
 def CreateSymbolicateCrashLogOptions(
 command_name,


Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
@@ -13,3 +13,5 @@
 # CHECK: [  1] {{.*}}out`bar + 8 at test.c
 # CHECK: [  2] {{.*}}out`main + 19 at test.c
 # CHECK: rbp = 0x7ffeec22a530
+# CHECK: invalid foo
+# CHECK: invalid bar
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
@@ -170,5 +170,9 @@
   "threadTriggered" : {
 "queue" : "com.apple.main-thread"
   }
-}
+},
+  "reportNotes" : [
+  "invalid foo",
+  "invalid bar"
+]
 }
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -330,6 +330,7 @@
 self.threads = list()
 self.backtraces = list()  # For application specific backtraces
 self.idents = list()  # A list of the required identifiers for doing all stack backtraces
+self.errors = list()
 self.crashed_thread_idx = -1
 self.version = -1
 self.target = None
@@ -433,6 +434,7 @@
 self.parse_process_info(self.data)
 self.parse_images(self.data['usedImages'])
 self.parse_threads(self.data['threads'])
+self.parse_errors(self.data)
 thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
 reason = self.parse_crash_reason(self.data['exception'])
 if thread.reason:
@@ -523,6 +525,10 @@
pass
 return registers
 
+def parse_errors(self, json_data):
+   if 'reportNotes' in json_data:
+  self.crashlog.errors = json_data['reportNotes']
+
 
 class CrashLogParseMode:
 NORMAL = 0
@@ -1062,6 +1068,11 @@
 thr

[Lldb-commits] [PATCH] D111341: [lldb] Support missing threadState in JSON crashlogs

2021-10-07 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere created this revision.
JDevlieghere added reviewers: jingham, aprantl.
JDevlieghere requested review of this revision.

Gracefully deal with JSON crashlogs that don't have thread state
available and print an error saying as much: "No thread state (register
information) available".

rdar://83955858


https://reviews.llvm.org/D111341

Files:
  lldb/examples/python/crashlog.py
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/no_threadState.ips
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no_threadState.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no_threadState.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no_threadState.test
@@ -0,0 +1,11 @@
+# RUN: %clang_host -g %S/Inputs/test.c -o %t.out
+
+# RUN: cp %S/Inputs/no_threadState.ips %t.crash
+# RUN: python %S/patch-crashlog.py --binary %t.out --crashlog %t.crash --offsets '{"main":20, "bar":9, "foo":16}' --json
+# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.crash' 2>&1 | FileCheck %s
+
+# CHECK: Thread[0] Crashing Thread Name EXC_BAD_ACCESS (SIGSEGV) (KERN_INVALID_ADDRESS at 0x)
+# CHECK: [  0] {{.*}}out`foo + 16 at test.c
+# CHECK: [  1] {{.*}}out`bar + 8 at test.c
+# CHECK: [  2] {{.*}}out`main + 19 at test.c
+# CHECK: No thread state (register information) available
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/no_threadState.ips
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/no_threadState.ips
@@ -0,0 +1,104 @@
+{"app_name":"json.test.tmp.out","timestamp":"2021-03-08 13:57:06.00 -0800","app_version":"","slice_uuid":"8f528c10-3e80-3dd6-b0be-5d558f64f7ab","build_version":"","platform":1,"share_with_app_devs":1,"is_first_party":1,"etl_key":"3","bug_type":"309","os_version":"macOS 11.3","incident_id":"FA21DF23-3344-4E45-BF27-4B8E63B7012B","name":"json.test.tmp.out"}
+{
+  "uptime" : 32,
+  "procLaunch" : "2021-03-08 13:56:51.7232 -0800",
+  "procRole" : "Unspecified",
+  "version" : 2,
+  "exception" : {
+"type" : "EXC_BAD_ACCESS",
+"signal" : "SIGSEGV",
+"subtype" : "KERN_INVALID_ADDRESS at 0x"
+  },
+  "userID" : 501,
+  "modelCode" : "iMacPro1,1",
+  "coalitionID" : 6086,
+  "osVersion" : {
+"train" : "macOS 11.3",
+"build" : "",
+"releaseType" : ""
+  },
+  "captureTime" : "2021-03-08 13:56:51.8610 -0800",
+  "incident" : "FA21DF23-3344-4E45-BF27-4B8E63B7012B",
+  "pid" : 72932,
+  "cpuType" : "X86-64",
+  "procName" : "json.test.tmp.out",
+  "procPath" : "\/Users\/USER\/*\/json.test.tmp.out",
+  "parentProc" : "fish",
+  "parentPid" : 67002,
+  "coalitionName" : "io.alacritty",
+  "crashReporterKey" : "DCEF35CB-68D5-F524-FF13-060901F52EA8",
+  "responsiblePid" : 65465,
+  "responsibleProc" : "alacritty",
+  "bridgeVersion" : {"build":"18P4544","train":"5.3"},
+  "sip" : "enabled",
+  "isCorpse" : 1,
+  "termination" : {"flags":0,"code":11,"namespace":"SIGNAL","indicator":"Segmentation fault: 11","byProc":"exc handler","byPid":72932},
+  "asi" : {"dyld":["dyld2 mode"]},
+  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":125361,"task_for_pid":9935},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
+  "faultingThread" : 0,
+  "threads" : [
+  {
+"triggered": true,
+"id": 6152004,
+"name": "Crashing Thread Name",
+"queue": "com.apple.main-thread",
+"frames": [
+  {
+"imageOffset": @foo@,
+"sourceLine": 3,
+"sourceFile": "test.c",
+"symbol": "foo",
+"imageIndex": 0,
+"symbolLocation": 16
+  },
+  {
+"imageOffset": @bar@,
+"sourceLine": 6,
+"sourceFile": "test.c",
+"symbol": "bar",
+"imageIndex": 0,
+"symbolLocation": 9
+  },
+  {
+"imageOffset": @main@,
+"sourceLine": 8,
+"sourceFile": "test.c",
+"symbol": "main",
+"imageIndex": 0,
+"symbolLocation": 20
+  },
+  {
+"imageOffset": 89917,
+"symbol": "start",
+"symbolLocation": 1,
+"imageIndex": 1
+  }
+]
+  }
+],
+  "usedImages" : [
+  {
+"source" : "P",
+"arch" : "x86_64",
+"base" : 4355608576,
+"size" : 16384,
+"uuid" : "@UUID@",
+"path" : "@EXEC@",
+"name" : "@NAME@"
+  },
+  {
+"source" : "P",
+"arch" : "x86_64",
+"base" : 140733734899712,
+"size" : 245760,
+"uuid" : "c5caf30b-0617-3b07-88c7-6319cd06f30a",
+"path" : "\/usr\/lib\/system\/libdyld.dylib",
+"name" : "libdyld.dylib"
+  }
+],
+  "legacyInfo" : {
+  "threadTriggered" : {
+"queue" : "com.apple.main-thread"
+  }
+}
+}
Index: lldb/examples/python/crashlog.py
===

[Lldb-commits] [PATCH] D111278: Recognize the Swift compiler in DW_AT_producer

2021-10-07 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:684
+  llvm::SmallVector matches;
+  if (g_swiftlang_version_regex.Execute(producer, &matches)) {
+  m_producer_version.tryParse(matches[1]);

JDevlieghere wrote:
> For consistency with the code below, should we first check if 
> `roducer.contains("swift")` and then execute the regex? Otherwise the 
> indentation on the line below is off. 
I think it makes more sense to run the clang regex right away. Matching the 
regex is faster than first searching for clang and then running the regex.


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

https://reviews.llvm.org/D111278

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


[Lldb-commits] [PATCH] D111278: Recognize the Swift compiler in DW_AT_producer

2021-10-07 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:684
+  llvm::SmallVector matches;
+  if (g_swiftlang_version_regex.Execute(producer, &matches)) {
+  m_producer_version.tryParse(matches[1]);

aprantl wrote:
> JDevlieghere wrote:
> > For consistency with the code below, should we first check if 
> > `roducer.contains("swift")` and then execute the regex? Otherwise the 
> > indentation on the line below is off. 
> I think it makes more sense to run the clang regex right away. Matching the 
> regex is faster than first searching for clang and then running the regex.
No, that does not preserve the semantics. We want to set the producer even if 
we can't parse the version. In any case, scanning the string twice in the Swift 
case is unnecessary.


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

https://reviews.llvm.org/D111278

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


[Lldb-commits] [PATCH] D111278: Recognize the Swift compiler in DW_AT_producer

2021-10-07 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl updated this revision to Diff 377977.
aprantl added a comment.

Const.


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

https://reviews.llvm.org/D111278

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp


Index: lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
===
--- lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
+++ lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
@@ -155,3 +155,39 @@
   ASSERT_TRUE((bool)unit);
   EXPECT_EQ(unit->GetProducer(), eProducerLLVMGCC);
 }
+
+TEST(DWARFUnitTest, SwiftProducer) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- 'Apple Swift version 5.5 (swiftlang-1300.0.31.1 clang-1300.0.29.1)'
+  debug_abbrev:
+- Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_producer
+  Form:DW_FORM_strp
+  debug_info:
+- Version: 4
+  AddrSize:8
+  Entries:
+- AbbrCode:0x1
+  Values:
+- Value:   0x0
+- AbbrCode:0x0
+)";
+
+  YAMLModuleTester t(yamldata);
+  DWARFUnit *unit = t.GetDwarfUnit();
+  ASSERT_TRUE((bool)unit);
+  EXPECT_EQ(unit->GetProducer(), eProducerSwift);
+  EXPECT_EQ(unit->GetProducerVersion(), llvm::VersionTuple(1300, 0, 31, 1));
+}
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -29,6 +29,7 @@
   eProducerClang,
   eProducerGCC,
   eProducerLLVMGCC,
+  eProducerSwift,
   eProducerOther
 };
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -671,22 +671,28 @@
   if (producer.empty())
 return;
 
+  static RegularExpression g_swiftlang_version_regex(
+  llvm::StringRef(R"(swiftlang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
+  static RegularExpression g_clang_version_regex(
+  llvm::StringRef(R"(clang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
   static RegularExpression g_llvm_gcc_regex(
   llvm::StringRef(R"(4\.[012]\.[01] )"
   R"(\(Based on Apple Inc\. build [0-9]+\) )"
   R"(\(LLVM build [\.0-9]+\)$)"));
-  static RegularExpression g_clang_version_regex(
-  llvm::StringRef(R"(clang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
 
-  if (g_llvm_gcc_regex.Execute(producer)) {
-m_producer = eProducerLLVMGCC;
+  llvm::SmallVector matches;
+  if (g_swiftlang_version_regex.Execute(producer, &matches)) {
+  m_producer_version.tryParse(matches[1]);
+m_producer = eProducerSwift;
   } else if (producer.contains("clang")) {
-llvm::SmallVector matches;
 if (g_clang_version_regex.Execute(producer, &matches))
   m_producer_version.tryParse(matches[1]);
 m_producer = eProducerClang;
-  } else if (producer.contains("GNU"))
+  } else if (producer.contains("GNU")) {
 m_producer = eProducerGCC;
+  } else if (g_llvm_gcc_regex.Execute(producer)) {
+m_producer = eProducerLLVMGCC;
+  }
 }
 
 DWARFProducer DWARFUnit::GetProducer() {


Index: lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
===
--- lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
+++ lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
@@ -155,3 +155,39 @@
   ASSERT_TRUE((bool)unit);
   EXPECT_EQ(unit->GetProducer(), eProducerLLVMGCC);
 }
+
+TEST(DWARFUnitTest, SwiftProducer) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- 'Apple Swift version 5.5 (swiftlang-1300.0.31.1 clang-1300.0.29.1)'
+  debug_abbrev:
+- Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_producer
+  Form:DW_FORM_strp
+  debug_info:
+- Version: 4
+  AddrSize:8
+  Entries:
+- AbbrCode:0x1
+  Values:
+- Value:   0x0
+- AbbrCode:0x0
+)";
+
+  YAMLModuleTester t(yamldata);
+  DWARFUnit *unit = t.GetDwarfUnit();
+  ASSERT_TRUE((bool)unit);
+  EXPECT_EQ(unit->GetProducer(), eProducerSwift);
+  EXPECT_EQ(unit->GetProducerVersion(), llvm::VersionTuple(1300, 0, 31, 1));
+}
Index: lldb/sour

[Lldb-commits] [PATCH] D111278: Recognize the Swift compiler in DW_AT_producer

2021-10-07 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




Comment at: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp:684
+  llvm::SmallVector matches;
+  if (g_swiftlang_version_regex.Execute(producer, &matches)) {
+  m_producer_version.tryParse(matches[1]);

aprantl wrote:
> JDevlieghere wrote:
> > For consistency with the code below, should we first check if 
> > `roducer.contains("swift")` and then execute the regex? Otherwise the 
> > indentation on the line below is off. 
> I think it makes more sense to run the clang regex right away. Matching the 
> regex is faster than first searching for clang and then running the regex.
Sounds reasonable to me. Should we do the same for clang? Then we just need to 
fix the indentation on line 685.


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

https://reviews.llvm.org/D111278

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


[Lldb-commits] [PATCH] D111339: [lldb] Parse and display reporting errors from JSON crashlogs

2021-10-07 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.

sgtm


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

https://reviews.llvm.org/D111339

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


[Lldb-commits] [lldb] 4651576 - Recognize the Swift compiler in DW_AT_producer

2021-10-07 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2021-10-07T13:54:28-07:00
New Revision: 4651576edd09bb4b0978db8592e938484e7bbd4f

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

LOG: Recognize the Swift compiler in DW_AT_producer

This patch adds support for Swift compiler producer strings to DWARFUnit.

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

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index 39411b54e036e..0eafd62eb9b9e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -671,22 +671,28 @@ void DWARFUnit::ParseProducerInfo() {
   if (producer.empty())
 return;
 
-  static RegularExpression g_llvm_gcc_regex(
+  static const RegularExpression g_swiftlang_version_regex(
+  llvm::StringRef(R"(swiftlang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
+  static const RegularExpression g_clang_version_regex(
+  llvm::StringRef(R"(clang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
+  static const RegularExpression g_llvm_gcc_regex(
   llvm::StringRef(R"(4\.[012]\.[01] )"
   R"(\(Based on Apple Inc\. build [0-9]+\) )"
   R"(\(LLVM build [\.0-9]+\)$)"));
-  static RegularExpression g_clang_version_regex(
-  llvm::StringRef(R"(clang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
 
-  if (g_llvm_gcc_regex.Execute(producer)) {
-m_producer = eProducerLLVMGCC;
+  llvm::SmallVector matches;
+  if (g_swiftlang_version_regex.Execute(producer, &matches)) {
+  m_producer_version.tryParse(matches[1]);
+m_producer = eProducerSwift;
   } else if (producer.contains("clang")) {
-llvm::SmallVector matches;
 if (g_clang_version_regex.Execute(producer, &matches))
   m_producer_version.tryParse(matches[1]);
 m_producer = eProducerClang;
-  } else if (producer.contains("GNU"))
+  } else if (producer.contains("GNU")) {
 m_producer = eProducerGCC;
+  } else if (g_llvm_gcc_regex.Execute(producer)) {
+m_producer = eProducerLLVMGCC;
+  }
 }
 
 DWARFProducer DWARFUnit::GetProducer() {

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
index 0e02da97fdb30..cece29dcf9ac8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -29,6 +29,7 @@ enum DWARFProducer {
   eProducerClang,
   eProducerGCC,
   eProducerLLVMGCC,
+  eProducerSwift,
   eProducerOther
 };
 

diff  --git a/lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp 
b/lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
index 85e3ae3cd8a5f..123acb6ea8e3f 100644
--- a/lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
+++ b/lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
@@ -155,3 +155,39 @@ TEST(DWARFUnitTest, LLVMGCCProducer) {
   ASSERT_TRUE((bool)unit);
   EXPECT_EQ(unit->GetProducer(), eProducerLLVMGCC);
 }
+
+TEST(DWARFUnitTest, SwiftProducer) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- 'Apple Swift version 5.5 (swiftlang-1300.0.31.1 clang-1300.0.29.1)'
+  debug_abbrev:
+- Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_producer
+  Form:DW_FORM_strp
+  debug_info:
+- Version: 4
+  AddrSize:8
+  Entries:
+- AbbrCode:0x1
+  Values:
+- Value:   0x0
+- AbbrCode:0x0
+)";
+
+  YAMLModuleTester t(yamldata);
+  DWARFUnit *unit = t.GetDwarfUnit();
+  ASSERT_TRUE((bool)unit);
+  EXPECT_EQ(unit->GetProducer(), eProducerSwift);
+  EXPECT_EQ(unit->GetProducerVersion(), llvm::VersionTuple(1300, 0, 31, 1));
+}



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


[Lldb-commits] [PATCH] D111278: Recognize the Swift compiler in DW_AT_producer

2021-10-07 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4651576edd09: Recognize the Swift compiler in DW_AT_producer 
(authored by aprantl).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D111278?vs=377977&id=378001#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111278

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
  lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp


Index: lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
===
--- lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
+++ lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
@@ -155,3 +155,39 @@
   ASSERT_TRUE((bool)unit);
   EXPECT_EQ(unit->GetProducer(), eProducerLLVMGCC);
 }
+
+TEST(DWARFUnitTest, SwiftProducer) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- 'Apple Swift version 5.5 (swiftlang-1300.0.31.1 clang-1300.0.29.1)'
+  debug_abbrev:
+- Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_producer
+  Form:DW_FORM_strp
+  debug_info:
+- Version: 4
+  AddrSize:8
+  Entries:
+- AbbrCode:0x1
+  Values:
+- Value:   0x0
+- AbbrCode:0x0
+)";
+
+  YAMLModuleTester t(yamldata);
+  DWARFUnit *unit = t.GetDwarfUnit();
+  ASSERT_TRUE((bool)unit);
+  EXPECT_EQ(unit->GetProducer(), eProducerSwift);
+  EXPECT_EQ(unit->GetProducerVersion(), llvm::VersionTuple(1300, 0, 31, 1));
+}
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h
@@ -29,6 +29,7 @@
   eProducerClang,
   eProducerGCC,
   eProducerLLVMGCC,
+  eProducerSwift,
   eProducerOther
 };
 
Index: lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -671,22 +671,28 @@
   if (producer.empty())
 return;
 
-  static RegularExpression g_llvm_gcc_regex(
+  static const RegularExpression g_swiftlang_version_regex(
+  llvm::StringRef(R"(swiftlang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
+  static const RegularExpression g_clang_version_regex(
+  llvm::StringRef(R"(clang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
+  static const RegularExpression g_llvm_gcc_regex(
   llvm::StringRef(R"(4\.[012]\.[01] )"
   R"(\(Based on Apple Inc\. build [0-9]+\) )"
   R"(\(LLVM build [\.0-9]+\)$)"));
-  static RegularExpression g_clang_version_regex(
-  llvm::StringRef(R"(clang-([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?))"));
 
-  if (g_llvm_gcc_regex.Execute(producer)) {
-m_producer = eProducerLLVMGCC;
+  llvm::SmallVector matches;
+  if (g_swiftlang_version_regex.Execute(producer, &matches)) {
+  m_producer_version.tryParse(matches[1]);
+m_producer = eProducerSwift;
   } else if (producer.contains("clang")) {
-llvm::SmallVector matches;
 if (g_clang_version_regex.Execute(producer, &matches))
   m_producer_version.tryParse(matches[1]);
 m_producer = eProducerClang;
-  } else if (producer.contains("GNU"))
+  } else if (producer.contains("GNU")) {
 m_producer = eProducerGCC;
+  } else if (g_llvm_gcc_regex.Execute(producer)) {
+m_producer = eProducerLLVMGCC;
+  }
 }
 
 DWARFProducer DWARFUnit::GetProducer() {


Index: lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
===
--- lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
+++ lldb/unittests/SymbolFile/DWARF/DWARFUnitTest.cpp
@@ -155,3 +155,39 @@
   ASSERT_TRUE((bool)unit);
   EXPECT_EQ(unit->GetProducer(), eProducerLLVMGCC);
 }
+
+TEST(DWARFUnitTest, SwiftProducer) {
+  const char *yamldata = R"(
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:ELFDATA2LSB
+  Type:ET_EXEC
+  Machine: EM_386
+DWARF:
+  debug_str:
+- 'Apple Swift version 5.5 (swiftlang-1300.0.31.1 clang-1300.0.29.1)'
+  debug_abbrev:
+- Table:
+- Code:0x0001
+  Tag: DW_TAG_compile_unit
+  Children:DW_CHILDREN_yes
+  Attributes:
+- Attribute:   DW_AT_producer
+  Form:DW_FORM_strp
+  debug_info:
+- Version: 4
+  AddrSize:8
+  Entries:
+- AbbrCode:0x1
+  Values:
+  

[Lldb-commits] [PATCH] D111355: [lldb] Add serial:// protocol for connecting to serial port [WIP/PoC]

2021-10-07 Thread Michał Górny via Phabricator via lldb-commits
mgorny created this revision.
mgorny added reviewers: labath, teemperor, krytarowski, emaste.
mgorny requested review of this revision.

Add a new serial:// protocol along with SerialPort that provides a new
API to open serial ports.  The URL consists of serial device path
followed by URL-style options, e.g.:

  serial:///dev/ttyS0?baud=115200&parity=even

If no options are provided, the serial port is only set to raw mode
and the other attributes remain unchanged.  Attributes provided via
options are modified to the specified values.  Upon closing the serial
port, its original attributes are restored.


https://reviews.llvm.org/D111355

Files:
  lldb/include/lldb/Host/File.h
  lldb/include/lldb/Host/posix/ConnectionFileDescriptorPosix.h
  lldb/source/Host/common/File.cpp
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp

Index: lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
===
--- lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
+++ lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
@@ -154,6 +154,7 @@
 #if LLDB_ENABLE_POSIX
   .Case("fd", &ConnectionFileDescriptor::ConnectFD)
   .Case("file", &ConnectionFileDescriptor::ConnectFile)
+  .Case("serial", &ConnectionFileDescriptor::ConnectSerialPort)
 #endif
   .Default(nullptr);
 
@@ -753,6 +754,89 @@
   llvm_unreachable("this function should be only called w/ LLDB_ENABLE_POSIX");
 }
 
+ConnectionStatus
+ConnectionFileDescriptor::ConnectSerialPort(llvm::StringRef s,
+Status *error_ptr) {
+#if LLDB_ENABLE_POSIX
+  llvm::StringRef path, params;
+  // serial:///PATH?k1=v1&k2=v2...
+  std::tie(path, params) = s.split('?');
+  int fd = llvm::sys::RetryAfterSignal(-1, ::open, path.str().c_str(), O_RDWR);
+  if (fd == -1) {
+if (error_ptr)
+  error_ptr->SetErrorToErrno();
+return eConnectionStatusError;
+  }
+
+  int flags = ::fcntl(fd, F_GETFL, 0);
+  if (flags >= 0) {
+if ((flags & O_NONBLOCK) == 0) {
+  flags |= O_NONBLOCK;
+  ::fcntl(fd, F_SETFL, flags);
+}
+  }
+
+  SerialPort::Options serial_options;
+  for (auto x : llvm::Split(params, '&')) {
+if (x.consume_front("baud=")) {
+  unsigned int baud_rate;
+  if (!llvm::to_integer(x, baud_rate, 10)) {
+if (error_ptr)
+  error_ptr->SetErrorStringWithFormat("invalid baud rate: \"%s\"",
+  x.str().c_str());
+return eConnectionStatusError;
+  }
+  serial_options.BaudRate = baud_rate;
+} else if (x.consume_front("parity=")) {
+  serial_options.Parity =
+  llvm::StringSwitch>(x)
+  .Case("no", TerminalParity::No)
+  .Case("even", TerminalParity::Even)
+  .Case("odd", TerminalParity::Odd)
+  .Case("mark", TerminalParity::Mark)
+  .Case("space", TerminalParity::Space)
+  .Default(llvm::None);
+  if (!serial_options.Parity) {
+if (error_ptr)
+  error_ptr->SetErrorStringWithFormat(
+  "invalid parity (must be no, even, odd, mark or space): \"%s\"",
+  x.str().c_str());
+return eConnectionStatusError;
+  }
+} else if (x.consume_front("stop-bits=")) {
+  unsigned int stop_bits;
+  if (!llvm::to_integer(x, stop_bits, 10) ||
+  (stop_bits != 1 && stop_bits != 2)) {
+if (error_ptr)
+  error_ptr->SetErrorStringWithFormat(
+  "invalid stop bits (must be 1 or 2): \"%s\"", x.str().c_str());
+return eConnectionStatusError;
+  }
+  serial_options.StopBits = stop_bits;
+} else {
+  if (error_ptr)
+error_ptr->SetErrorStringWithFormat("unknown parameter: \"%s\"",
+x.str().c_str());
+  return eConnectionStatusError;
+}
+  }
+
+  m_read_sp = std::make_shared(fd, File::eOpenOptionReadWrite,
+   serial_options, true);
+  if (!m_read_sp->IsValid()) {
+m_read_sp.reset();
+if (error_ptr)
+  error_ptr->SetErrorStringWithFormat("path is not a tty: \"%s\"",
+  path.str().c_str());
+return eConnectionStatusError;
+  }
+  m_write_sp = m_read_sp;
+
+  return eConnectionStatusSuccess;
+#endif // LLDB_ENABLE_POSIX
+  llvm_unreachable("this function should be only called w/ LLDB_ENABLE_POSIX");
+}
+
 uint16_t
 ConnectionFileDescriptor::GetListeningPort(const Timeout &timeout) {
   auto Result = m_port_predicate.WaitForValueNotEqualTo(0, timeout);
Index: lldb/source/Host/common/File.cpp
===
--- lldb/source/Host/common/File.cpp
+++ lldb/source/Host/common/File.cpp
@@ -769,5 +769,28 @@
   return mode;
 }
 
+SerialPort::SerialPort(int fd, OpenOptions options,
+   SerialPort::Options serial_options,
+

[Lldb-commits] [lldb] b913065 - [lldb] Support missing threadState in JSON crashlogs

2021-10-07 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-10-07T15:53:52-07:00
New Revision: b913065bf470bcaf1ee8ff8b6a647b877110a4ba

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

LOG: [lldb] Support missing threadState in JSON crashlogs

Gracefully deal with JSON crashlogs that don't have thread state
available and print an error saying as much: "No thread state (register
information) available".

rdar://83955858

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

Added: 
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/no_threadState.ips
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no_threadState.test

Modified: 
lldb/examples/python/crashlog.py

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index aec4096585222..ae4263b76cba2 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -83,6 +83,7 @@ def __init__(self, index, app_specific_backtrace):
 self.registers = dict()
 self.reason = None
 self.queue = None
+self.crashed = False
 self.app_specific_backtrace = app_specific_backtrace
 
 def dump(self, prefix):
@@ -160,6 +161,9 @@ def dump_symbolicated(self, crash_log, options):
 print()
 for reg in self.registers.keys():
 print("%-8s = %#16.16x" % (reg, self.registers[reg]))
+elif self.crashed:
+   print()
+   print("No thread state (register information) available")
 
 def add_ident(self, ident):
 if ident not in self.idents:
@@ -505,8 +509,10 @@ def parse_threads(self, json_threads):
 thread.reason = json_thread['name']
 if json_thread.get('triggered', False):
 self.crashlog.crashed_thread_idx = idx
-thread.registers = self.parse_thread_registers(
-json_thread['threadState'])
+thread.crashed = True
+if 'threadState' in json_thread:
+thread.registers = self.parse_thread_registers(
+json_thread['threadState'])
 thread.queue = json_thread.get('queue')
 self.parse_frames(thread, json_thread.get('frames', []))
 self.crashlog.threads.append(thread)

diff  --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/no_threadState.ips 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/no_threadState.ips
new file mode 100644
index 0..925e6cd41397d
--- /dev/null
+++ 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/no_threadState.ips
@@ -0,0 +1,104 @@
+{"app_name":"json.test.tmp.out","timestamp":"2021-03-08 13:57:06.00 
-0800","app_version":"","slice_uuid":"8f528c10-3e80-3dd6-b0be-5d558f64f7ab","build_version":"","platform":1,"share_with_app_devs":1,"is_first_party":1,"etl_key":"3","bug_type":"309","os_version":"macOS
 
11.3","incident_id":"FA21DF23-3344-4E45-BF27-4B8E63B7012B","name":"json.test.tmp.out"}
+{
+  "uptime" : 32,
+  "procLaunch" : "2021-03-08 13:56:51.7232 -0800",
+  "procRole" : "Unspecified",
+  "version" : 2,
+  "exception" : {
+"type" : "EXC_BAD_ACCESS",
+"signal" : "SIGSEGV",
+"subtype" : "KERN_INVALID_ADDRESS at 0x"
+  },
+  "userID" : 501,
+  "modelCode" : "iMacPro1,1",
+  "coalitionID" : 6086,
+  "osVersion" : {
+"train" : "macOS 11.3",
+"build" : "",
+"releaseType" : ""
+  },
+  "captureTime" : "2021-03-08 13:56:51.8610 -0800",
+  "incident" : "FA21DF23-3344-4E45-BF27-4B8E63B7012B",
+  "pid" : 72932,
+  "cpuType" : "X86-64",
+  "procName" : "json.test.tmp.out",
+  "procPath" : "\/Users\/USER\/*\/json.test.tmp.out",
+  "parentProc" : "fish",
+  "parentPid" : 67002,
+  "coalitionName" : "io.alacritty",
+  "crashReporterKey" : "DCEF35CB-68D5-F524-FF13-060901F52EA8",
+  "responsiblePid" : 65465,
+  "responsibleProc" : "alacritty",
+  "bridgeVersion" : {"build":"18P4544","train":"5.3"},
+  "sip" : "enabled",
+  "isCorpse" : 1,
+  "termination" : 
{"flags":0,"code":11,"namespace":"SIGNAL","indicator":"Segmentation fault: 
11","byProc":"exc handler","byPid":72932},
+  "asi" : {"dyld":["dyld2 mode"]},
+  "extMods" : 
{"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":125361,"task_for_pid":9935},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
+  "faultingThread" : 0,
+  "threads" : [
+  {
+"triggered": true,
+"id": 6152004,
+"name": "Crashing Thread Name",
+"queue": "com.apple.main-thread",
+"frames": [
+  {
+"imageOffset": @foo@,
+"sourceLine": 3,
+"sourceFile": "test.c",
+"symbol": "fo

[Lldb-commits] [lldb] b225c5f - [lldb] Parse and display reporting errors from JSON crashlogs

2021-10-07 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2021-10-07T15:53:52-07:00
New Revision: b225c5f7861c7f99de3d52dc1ed23e358c5cce36

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

LOG: [lldb] Parse and display reporting errors from JSON crashlogs

JSON crashlogs have an optional field named reportNotes that contains
any potential errors encountered by the crash reporter when generating
the crashlog. Parse and display them in LLDB.

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

Added: 


Modified: 
lldb/examples/python/crashlog.py
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test

Removed: 




diff  --git a/lldb/examples/python/crashlog.py 
b/lldb/examples/python/crashlog.py
index ae4263b76cba..242ded01817f 100755
--- a/lldb/examples/python/crashlog.py
+++ b/lldb/examples/python/crashlog.py
@@ -334,6 +334,7 @@ def __init__(self, debugger, path, verbose):
 self.threads = list()
 self.backtraces = list()  # For application specific backtraces
 self.idents = list()  # A list of the required identifiers for doing 
all stack backtraces
+self.errors = list()
 self.crashed_thread_idx = -1
 self.version = -1
 self.target = None
@@ -437,6 +438,7 @@ def parse(self):
 self.parse_process_info(self.data)
 self.parse_images(self.data['usedImages'])
 self.parse_threads(self.data['threads'])
+self.parse_errors(self.data)
 thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
 reason = self.parse_crash_reason(self.data['exception'])
 if thread.reason:
@@ -528,6 +530,10 @@ def parse_thread_registers(self, json_thread_state):
pass
 return registers
 
+def parse_errors(self, json_data):
+   if 'reportNotes' in json_data:
+  self.crashlog.errors = json_data['reportNotes']
+
 
 class CrashLogParseMode:
 NORMAL = 0
@@ -1067,6 +1073,11 @@ def SymbolicateCrashLog(crash_log, options):
 thread.dump_symbolicated(crash_log, options)
 print()
 
+if crash_log.errors:
+print("Errors:")
+for error in crash_log.errors:
+print(error)
+
 
 def CreateSymbolicateCrashLogOptions(
 command_name,

diff  --git 
a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
index 5446d0d9973a..109ac2ba2485 100644
--- a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
+++ b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
@@ -170,5 +170,9 @@
   "threadTriggered" : {
 "queue" : "com.apple.main-thread"
   }
-}
+},
+  "reportNotes" : [
+  "invalid foo",
+  "invalid bar"
+]
 }

diff  --git a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test 
b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
index 0c522e9d202b..b70cd44c0c8e 100644
--- a/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
+++ b/lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
@@ -13,3 +13,5 @@
 # CHECK: [  1] {{.*}}out`bar + 8 at test.c
 # CHECK: [  2] {{.*}}out`main + 19 at test.c
 # CHECK: rbp = 0x7ffeec22a530
+# CHECK: invalid foo
+# CHECK: invalid bar



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


[Lldb-commits] [PATCH] D111341: [lldb] Support missing threadState in JSON crashlogs

2021-10-07 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb913065bf470: [lldb] Support missing threadState in JSON 
crashlogs (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111341

Files:
  lldb/examples/python/crashlog.py
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/no_threadState.ips
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no_threadState.test

Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no_threadState.test
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/no_threadState.test
@@ -0,0 +1,11 @@
+# RUN: %clang_host -g %S/Inputs/test.c -o %t.out
+
+# RUN: cp %S/Inputs/no_threadState.ips %t.crash
+# RUN: python %S/patch-crashlog.py --binary %t.out --crashlog %t.crash --offsets '{"main":20, "bar":9, "foo":16}' --json
+# RUN: %lldb %t.out -o 'command script import lldb.macosx.crashlog' -o 'crashlog %t.crash' 2>&1 | FileCheck %s
+
+# CHECK: Thread[0] Crashing Thread Name EXC_BAD_ACCESS (SIGSEGV) (KERN_INVALID_ADDRESS at 0x)
+# CHECK: [  0] {{.*}}out`foo + 16 at test.c
+# CHECK: [  1] {{.*}}out`bar + 8 at test.c
+# CHECK: [  2] {{.*}}out`main + 19 at test.c
+# CHECK: No thread state (register information) available
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/no_threadState.ips
===
--- /dev/null
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/no_threadState.ips
@@ -0,0 +1,104 @@
+{"app_name":"json.test.tmp.out","timestamp":"2021-03-08 13:57:06.00 -0800","app_version":"","slice_uuid":"8f528c10-3e80-3dd6-b0be-5d558f64f7ab","build_version":"","platform":1,"share_with_app_devs":1,"is_first_party":1,"etl_key":"3","bug_type":"309","os_version":"macOS 11.3","incident_id":"FA21DF23-3344-4E45-BF27-4B8E63B7012B","name":"json.test.tmp.out"}
+{
+  "uptime" : 32,
+  "procLaunch" : "2021-03-08 13:56:51.7232 -0800",
+  "procRole" : "Unspecified",
+  "version" : 2,
+  "exception" : {
+"type" : "EXC_BAD_ACCESS",
+"signal" : "SIGSEGV",
+"subtype" : "KERN_INVALID_ADDRESS at 0x"
+  },
+  "userID" : 501,
+  "modelCode" : "iMacPro1,1",
+  "coalitionID" : 6086,
+  "osVersion" : {
+"train" : "macOS 11.3",
+"build" : "",
+"releaseType" : ""
+  },
+  "captureTime" : "2021-03-08 13:56:51.8610 -0800",
+  "incident" : "FA21DF23-3344-4E45-BF27-4B8E63B7012B",
+  "pid" : 72932,
+  "cpuType" : "X86-64",
+  "procName" : "json.test.tmp.out",
+  "procPath" : "\/Users\/USER\/*\/json.test.tmp.out",
+  "parentProc" : "fish",
+  "parentPid" : 67002,
+  "coalitionName" : "io.alacritty",
+  "crashReporterKey" : "DCEF35CB-68D5-F524-FF13-060901F52EA8",
+  "responsiblePid" : 65465,
+  "responsibleProc" : "alacritty",
+  "bridgeVersion" : {"build":"18P4544","train":"5.3"},
+  "sip" : "enabled",
+  "isCorpse" : 1,
+  "termination" : {"flags":0,"code":11,"namespace":"SIGNAL","indicator":"Segmentation fault: 11","byProc":"exc handler","byPid":72932},
+  "asi" : {"dyld":["dyld2 mode"]},
+  "extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":125361,"task_for_pid":9935},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
+  "faultingThread" : 0,
+  "threads" : [
+  {
+"triggered": true,
+"id": 6152004,
+"name": "Crashing Thread Name",
+"queue": "com.apple.main-thread",
+"frames": [
+  {
+"imageOffset": @foo@,
+"sourceLine": 3,
+"sourceFile": "test.c",
+"symbol": "foo",
+"imageIndex": 0,
+"symbolLocation": 16
+  },
+  {
+"imageOffset": @bar@,
+"sourceLine": 6,
+"sourceFile": "test.c",
+"symbol": "bar",
+"imageIndex": 0,
+"symbolLocation": 9
+  },
+  {
+"imageOffset": @main@,
+"sourceLine": 8,
+"sourceFile": "test.c",
+"symbol": "main",
+"imageIndex": 0,
+"symbolLocation": 20
+  },
+  {
+"imageOffset": 89917,
+"symbol": "start",
+"symbolLocation": 1,
+"imageIndex": 1
+  }
+]
+  }
+],
+  "usedImages" : [
+  {
+"source" : "P",
+"arch" : "x86_64",
+"base" : 4355608576,
+"size" : 16384,
+"uuid" : "@UUID@",
+"path" : "@EXEC@",
+"name" : "@NAME@"
+  },
+  {
+"source" : "P",
+"arch" : "x86_64",
+"base" : 140733734899712,
+"size" : 245760,
+"uuid" : "c5caf30b-0617-3b07-88c7-6319cd06f30a",
+"path" : "\/usr\/lib\/system\/libdyld.dylib",
+"name" : "libdyld.dylib"
+  }
+],
+  "legacyInfo" : {
+  "threadTriggered" : {
+"queue" : "com.apple.main-thread"
+  }
+}
+}
Index: lldb/examples/python/crashlog.py
===

[Lldb-commits] [PATCH] D111339: [lldb] Parse and display reporting errors from JSON crashlogs

2021-10-07 Thread Jonas Devlieghere via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb225c5f7861c: [lldb] Parse and display reporting errors from 
JSON crashlogs (authored by JDevlieghere).
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111339

Files:
  lldb/examples/python/crashlog.py
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
  lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test


Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
@@ -13,3 +13,5 @@
 # CHECK: [  1] {{.*}}out`bar + 8 at test.c
 # CHECK: [  2] {{.*}}out`main + 19 at test.c
 # CHECK: rbp = 0x7ffeec22a530
+# CHECK: invalid foo
+# CHECK: invalid bar
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
@@ -170,5 +170,9 @@
   "threadTriggered" : {
 "queue" : "com.apple.main-thread"
   }
-}
+},
+  "reportNotes" : [
+  "invalid foo",
+  "invalid bar"
+]
 }
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -334,6 +334,7 @@
 self.threads = list()
 self.backtraces = list()  # For application specific backtraces
 self.idents = list()  # A list of the required identifiers for doing 
all stack backtraces
+self.errors = list()
 self.crashed_thread_idx = -1
 self.version = -1
 self.target = None
@@ -437,6 +438,7 @@
 self.parse_process_info(self.data)
 self.parse_images(self.data['usedImages'])
 self.parse_threads(self.data['threads'])
+self.parse_errors(self.data)
 thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
 reason = self.parse_crash_reason(self.data['exception'])
 if thread.reason:
@@ -528,6 +530,10 @@
pass
 return registers
 
+def parse_errors(self, json_data):
+   if 'reportNotes' in json_data:
+  self.crashlog.errors = json_data['reportNotes']
+
 
 class CrashLogParseMode:
 NORMAL = 0
@@ -1067,6 +1073,11 @@
 thread.dump_symbolicated(crash_log, options)
 print()
 
+if crash_log.errors:
+print("Errors:")
+for error in crash_log.errors:
+print(error)
+
 
 def CreateSymbolicateCrashLogOptions(
 command_name,


Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/json.test
@@ -13,3 +13,5 @@
 # CHECK: [  1] {{.*}}out`bar + 8 at test.c
 # CHECK: [  2] {{.*}}out`main + 19 at test.c
 # CHECK: rbp = 0x7ffeec22a530
+# CHECK: invalid foo
+# CHECK: invalid bar
Index: lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
===
--- lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
+++ lldb/test/Shell/ScriptInterpreter/Python/Crashlog/Inputs/a.out.ips
@@ -170,5 +170,9 @@
   "threadTriggered" : {
 "queue" : "com.apple.main-thread"
   }
-}
+},
+  "reportNotes" : [
+  "invalid foo",
+  "invalid bar"
+]
 }
Index: lldb/examples/python/crashlog.py
===
--- lldb/examples/python/crashlog.py
+++ lldb/examples/python/crashlog.py
@@ -334,6 +334,7 @@
 self.threads = list()
 self.backtraces = list()  # For application specific backtraces
 self.idents = list()  # A list of the required identifiers for doing all stack backtraces
+self.errors = list()
 self.crashed_thread_idx = -1
 self.version = -1
 self.target = None
@@ -437,6 +438,7 @@
 self.parse_process_info(self.data)
 self.parse_images(self.data['usedImages'])
 self.parse_threads(self.data['threads'])
+self.parse_errors(self.data)
 thread = self.crashlog.threads[self.crashlog.crashed_thread_idx]
 reason = self.parse_crash_reason(self.data['exception'])
 if thread.reason:
@@ -528,6 +530,10 @@
pass
 return registers
 
+def parse_errors(self, json_data):
+   if 'reportNotes' in json_data:
+  self.crashlog.errors = json_data['reportNotes']
+
 
 class CrashLogParseMode:
 NORMAL = 0
@@ -1067,6 +1073,11 @@