[Lldb-commits] [lldb] 4ba9d9c - Use StringRef::contains (NFC)

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

Author: Kazu Hirata
Date: 2021-10-23T20:41:46-07:00
New Revision: 4ba9d9c84f4ce05eec341dc5f2d1c95934ab3d2c

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

LOG: Use StringRef::contains (NFC)

Added: 


Modified: 
clang-tools-extra/modularize/CoverageChecker.cpp
lld/COFF/PDB.cpp
lldb/source/Commands/CommandObjectWatchpoint.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/tools/lldb-vscode/lldb-vscode.cpp
mlir/lib/IR/MLIRContext.cpp

Removed: 




diff  --git a/clang-tools-extra/modularize/CoverageChecker.cpp 
b/clang-tools-extra/modularize/CoverageChecker.cpp
index b115d59aaba85..b1c787862c02d 100644
--- a/clang-tools-extra/modularize/CoverageChecker.cpp
+++ b/clang-tools-extra/modularize/CoverageChecker.cpp
@@ -381,8 +381,7 @@ bool CoverageChecker::collectFileSystemHeaders(StringRef 
IncludePath) {
   continue;
 // Assume directories or files starting with '.' are private and not to
 // be considered.
-if ((file.find("\\.") != StringRef::npos) ||
-(file.find("/.") != StringRef::npos))
+if (file.contains("\\.") || file.contains("/."))
   continue;
 // If the file does not have a common header extension, ignore it.
 if (!ModularizeUtilities::isHeader(file))

diff  --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp
index 73feddaa202d8..00e171017f4bf 100644
--- a/lld/COFF/PDB.cpp
+++ b/lld/COFF/PDB.cpp
@@ -1347,8 +1347,8 @@ static std::string quote(ArrayRef args) {
   for (StringRef a : args) {
 if (!r.empty())
   r.push_back(' ');
-bool hasWS = a.find(' ') != StringRef::npos;
-bool hasQ = a.find('"') != StringRef::npos;
+bool hasWS = a.contains(' ');
+bool hasQ = a.contains('"');
 if (hasWS || hasQ)
   r.push_back('"');
 if (hasQ) {

diff  --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp 
b/lldb/source/Commands/CommandObjectWatchpoint.cpp
index d7a446fc366c5..9fbf036a19d1a 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -56,7 +56,7 @@ static int32_t WithRSAIndex(llvm::StringRef Arg) {
 
   uint32_t i;
   for (i = 0; i < 4; ++i)
-if (Arg.find(RSA[i]) != llvm::StringRef::npos)
+if (Arg.contains(RSA[i]))
   return i;
   return -1;
 }

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index d9ab17eece888..a0cff3cc9bf8e 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1309,7 +1309,7 @@ static bool FindFunctionInModule(ConstString 
_name,
  llvm::Module *module, const char *orig_name) {
   for (const auto  : module->getFunctionList()) {
 const StringRef  = func.getName();
-if (name.find(orig_name) != StringRef::npos) {
+if (name.contains(orig_name)) {
   mangled_name.SetString(name);
   return true;
 }

diff  --git 
a/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
index b24bcc1344e23..8ecf6712eace2 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/MSVCUndecoratedNameParser.cpp
@@ -72,7 +72,7 @@ 
MSVCUndecoratedNameParser::MSVCUndecoratedNameParser(llvm::StringRef name) {
 }
 
 bool MSVCUndecoratedNameParser::IsMSVCUndecoratedName(llvm::StringRef name) {
-  return name.find('`') != llvm::StringRef::npos;
+  return name.contains('`');
 }
 
 bool MSVCUndecoratedNameParser::ExtractContextAndIdentifier(

diff  --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
index 9550cb53e9e83..a43f8c004aaae 100644
--- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -1543,17 +1543,17 @@ Status 
GDBRemoteCommunicationClient::GetMemoryRegionInfo(
region_info.GetRange().IsValid()) {
   saw_permissions = true;
   if (region_info.GetRange().Contains(addr)) {
-if (value.find('r') != llvm::StringRef::npos)
+if (value.contains('r'))
   region_info.SetReadable(MemoryRegionInfo::eYes);
 else
   region_info.SetReadable(MemoryRegionInfo::eNo);
 
-if (value.find('w') != llvm::StringRef::npos)
+if 

[Lldb-commits] [PATCH] D112212: [lldb/test] Print build commands in trace mode

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

In D112212#3081935 , @dblaikie wrote:

> In D112212#3081828 , @JDevlieghere 
> wrote:
>
>> In D112212#3080491 , @teemperor 
>> wrote:
>>
>>> This LGTM, but `shlex.join` is actually Py3 exclusive and I don't think 
>>> there is a good Py2 replacement. I think we're just in time for the Py2->3 
>>> migration according to the timeline Jonas posted last year 
>>> , so 
>>> let's use this patch to actually do that? Then we can also get rid of all 
>>> the `six` stuff etc.
>>>
>>> Let's see if Jonas has any objections against dropping Py2 with this, 
>>> otherwise this is good to go.
>>
>> We're planning to branch from open source on October 26th. If there's no 
>> urgency, it would really be great if we can hold off breaking Py2 until then.
>>
>> I'm all in favor for getting rid of Python 2 support, but sweeping changes 
>> like dropping the `six` stuff will introduce a lot of headaches (merge 
>> conflicts) for us. If we could postpone that for another release that would 
>> save us a bunch of engineering time.
>
> No judgment (I think it's a reasonable request to punt a patch like this a 
> few days if it helps out major contributors) - but I'm curious/just not quite 
> wrapping my head around: Why would it be easier if this sort of patch went in 
> after you branch? I'd have thought it'd be easier if it goes in before the 
> branch. That way when you're backporting patches from upstream after the 
> branch there will be fewer unrelated changes/merge conflicts, yeah?

The patch introduces a dependency on Python 3 and unfortunately we still have a 
small (but important) group of users that haven't fully migrated yet. If the 
patch were to land before the branch, I'd have to revert it (same result) or 
find a way to do what `shlex.join` does in Python 2. I did a quick search 
yesterday and didn't immediately find a good alternative and with the timeline 
I've given in the past, I also don't think the burden should be on the patch 
author (Pavel). So that's why I suggested holding off on landing it. If it does 
turn out to cause a lot of conflicts, I can always reconsider.

But yes, backporting is a real concern, which is the main reason I'm asking not 
to start making big mechanical changes like replacing all the `six` stuff 
unless there's a pressing reason to do so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112212

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


[Lldb-commits] [PATCH] D112365: [lldb] Support serial port parity checking

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

https://reviews.llvm.org/D112365

Files:
  lldb/include/lldb/Host/File.h
  lldb/include/lldb/Host/Terminal.h
  lldb/source/Host/common/File.cpp
  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
@@ -190,6 +190,36 @@
 #endif
 }
 
+TEST_F(TerminalTest, SetParityCheck) {
+  struct termios terminfo;
+
+  ASSERT_THAT_ERROR(m_term.SetParityCheck(Terminal::ParityCheck::No),
+llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  EXPECT_EQ(terminfo.c_iflag & (IGNPAR | PARMRK | INPCK), 0U);
+
+  ASSERT_THAT_ERROR(
+  m_term.SetParityCheck(Terminal::ParityCheck::ReplaceWithNUL),
+  llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  EXPECT_NE(terminfo.c_iflag & INPCK, 0U);
+  EXPECT_EQ(terminfo.c_iflag & (IGNPAR | PARMRK), 0U);
+
+  ASSERT_THAT_ERROR(m_term.SetParityCheck(Terminal::ParityCheck::Ignore),
+llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  EXPECT_NE(terminfo.c_iflag & IGNPAR, 0U);
+  EXPECT_EQ(terminfo.c_iflag & PARMRK, 0U);
+  EXPECT_NE(terminfo.c_iflag & INPCK, 0U);
+
+  ASSERT_THAT_ERROR(m_term.SetParityCheck(Terminal::ParityCheck::Mark),
+llvm::Succeeded());
+  ASSERT_EQ(tcgetattr(m_fd, ), 0);
+  EXPECT_EQ(terminfo.c_iflag & IGNPAR, 0U);
+  EXPECT_NE(terminfo.c_iflag & PARMRK, 0U);
+  EXPECT_NE(terminfo.c_iflag & INPCK, 0U);
+}
+
 TEST_F(TerminalTest, SetHardwareFlowControl) {
 #if defined(CRTSCTS)
   struct termios terminfo;
Index: lldb/source/Host/common/Terminal.cpp
===
--- lldb/source/Host/common/Terminal.cpp
+++ lldb/source/Host/common/Terminal.cpp
@@ -335,6 +335,26 @@
 #endif // #if LLDB_ENABLE_TERMIOS
 }
 
+llvm::Error Terminal::SetParityCheck(Terminal::ParityCheck parity_check) {
+  llvm::Expected data = GetData();
+  if (!data)
+return data.takeError();
+
+#if LLDB_ENABLE_TERMIOS
+  struct termios _termios = data->m_termios;
+  fd_termios.c_iflag &= ~(IGNPAR | PARMRK | INPCK);
+
+  if (parity_check != ParityCheck::No) {
+fd_termios.c_iflag |= INPCK;
+if (parity_check == ParityCheck::Ignore)
+  fd_termios.c_iflag |= IGNPAR;
+else if (parity_check == ParityCheck::Mark)
+  fd_termios.c_iflag |= PARMRK;
+  }
+  return SetData(data.get());
+#endif // #if LLDB_ENABLE_TERMIOS
+}
+
 llvm::Error Terminal::SetHardwareFlowControl(bool enabled) {
   llvm::Expected data = GetData();
   if (!data)
Index: lldb/source/Host/common/File.cpp
===
--- lldb/source/Host/common/File.cpp
+++ lldb/source/Host/common/File.cpp
@@ -794,6 +794,21 @@
 llvm::inconvertibleErrorCode(),
 "Invalid parity (must be no, even, odd, mark or space): %s",
 x.str().c_str());
+} else if (x.consume_front("parity-check=")) {
+  serial_options.ParityCheck =
+  llvm::StringSwitch>(x)
+  .Case("no", Terminal::ParityCheck::No)
+  .Case("replace", Terminal::ParityCheck::ReplaceWithNUL)
+  .Case("ignore", Terminal::ParityCheck::Ignore)
+  // "mark" mode is not currently supported as it requires special
+  // input processing
+  // .Case("mark", Terminal::ParityCheck::Mark)
+  .Default(llvm::None);
+  if (!serial_options.ParityCheck)
+return llvm::createStringError(
+llvm::inconvertibleErrorCode(),
+"Invalid parity-check (must be no, replace, ignore or mark): %s",
+x.str().c_str());
 } else if (x.consume_front("stop-bits=")) {
   unsigned int stop_bits;
   if (!llvm::to_integer(x, stop_bits, 10) ||
@@ -831,6 +846,11 @@
 if (llvm::Error error = term.SetParity(serial_options.Parity.getValue()))
   return std::move(error);
   }
+  if (serial_options.ParityCheck) {
+if (llvm::Error error =
+term.SetParityCheck(serial_options.ParityCheck.getValue()))
+  return std::move(error);
+  }
   if (serial_options.StopBits) {
 if (llvm::Error error =
 term.SetStopBits(serial_options.StopBits.getValue()))
Index: lldb/include/lldb/Host/Terminal.h
===
--- lldb/include/lldb/Host/Terminal.h
+++ lldb/include/lldb/Host/Terminal.h
@@ -28,6 +28,18 @@
 Mark,
   };
 
+  enum class ParityCheck {
+// No parity checking
+No,
+// Replace erraneous bytes with NUL
+ReplaceWithNUL,
+// Ignore erraneous bytes
+Ignore,
+// Mark erraneous bytes by prepending them with \xFF\x00; real \xFF
+// is escaped to \xFF\xFF
+Mark,
+  };
+

[Lldb-commits] [lldb] d8e4170 - Ensure newlines at the end of files (NFC)

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

Author: Kazu Hirata
Date: 2021-10-23T08:45:29-07:00
New Revision: d8e4170b0a1431edee939efc16b60b409affcb4d

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

LOG: Ensure newlines at the end of files (NFC)

Added: 


Modified: 
clang-tools-extra/clangd/HeuristicResolver.cpp
clang/docs/analyzer/developer-docs.rst
clang/lib/Driver/ToolChains/AMDGPU.cpp
clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
libc/test/src/string/memory_utils/CMakeLists.txt
libcxx/benchmarks/algorithms.bench.cpp
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
llvm/docs/TableGen/BackGuide.rst
llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h
llvm/lib/Analysis/OverflowInstAnalysis.cpp
llvm/lib/CodeGen/CodeGenCommonISel.cpp
llvm/lib/Support/DebugOptions.h
llvm/lib/Target/AMDGPU/MCA/CMakeLists.txt
llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp
llvm/lib/Target/CSKY/AsmParser/CSKYAsmParser.cpp
llvm/lib/Target/CSKY/CSKYInstrFormats.td
llvm/lib/Target/CSKY/CSKYInstrInfo.td
llvm/lib/Target/CSKY/CSKYSubtarget.cpp
llvm/lib/Target/CSKY/CSKYSubtarget.h
llvm/lib/Target/CSKY/MCTargetDesc/CSKYFixupKinds.h
llvm/lib/Target/CSKY/MCTargetDesc/CSKYInstPrinter.h
llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCCodeEmitter.cpp
llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCCodeEmitter.h
llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.cpp
llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCExpr.h
llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCTargetDesc.h
llvm/tools/llvm-exegesis/lib/SnippetFile.h
mlir/lib/Bindings/Python/Pass.h
mlir/lib/Dialect/Linalg/Transforms/LinalgStrategyPasses.cpp
openmp/libomptarget/plugins/ppc64/CMakeLists.txt
openmp/libomptarget/plugins/ppc64le/CMakeLists.txt
openmp/libomptarget/plugins/x86_64/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/HeuristicResolver.cpp 
b/clang-tools-extra/clangd/HeuristicResolver.cpp
index b0a7448a04ef0..2505280ffa9aa 100644
--- a/clang-tools-extra/clangd/HeuristicResolver.cpp
+++ b/clang-tools-extra/clangd/HeuristicResolver.cpp
@@ -266,4 +266,4 @@ std::vector 
HeuristicResolver::resolveDependentMember(
 }
 
 } // namespace clangd
-} // namespace clang
\ No newline at end of file
+} // namespace clang

diff  --git a/clang/docs/analyzer/developer-docs.rst 
b/clang/docs/analyzer/developer-docs.rst
index a3d74a765f933..5f430ca7e11bd 100644
--- a/clang/docs/analyzer/developer-docs.rst
+++ b/clang/docs/analyzer/developer-docs.rst
@@ -11,4 +11,4 @@ Contents:
developer-docs/InitializerLists
developer-docs/nullability
developer-docs/RegionStore
-   
\ No newline at end of file
+   

diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp 
b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index a29ed0bdc6b4c..586a1484cd248 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -927,4 +927,4 @@ ROCMToolChain::getCommonDeviceLibNames(const 
llvm::opt::ArgList ,
   return RocmInstallation.getCommonBitcodeLibs(
   DriverArgs, LibDeviceFile, Wave64, DAZ, FiniteOnly, UnsafeMathOpt,
   FastRelaxedMath, CorrectSqrt);
-}
\ No newline at end of file
+}

diff  --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index dd65f8c035aa1..cc27bd27abe79 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -1118,4 +1118,4 @@ void ento::registerStreamTesterChecker(CheckerManager 
) {
 
 bool ento::shouldRegisterStreamTesterChecker(const CheckerManager ) {
   return true;
-}
\ No newline at end of file
+}

diff  --git a/libc/test/src/string/memory_utils/CMakeLists.txt 
b/libc/test/src/string/memory_utils/CMakeLists.txt
index a1e2c90234063..9f2950dc56582 100644
--- a/libc/test/src/string/memory_utils/CMakeLists.txt
+++ b/libc/test/src/string/memory_utils/CMakeLists.txt
@@ -12,4 +12,4 @@ add_libc_unittest(
   COMPILE_OPTIONS
 ${LIBC_COMPILE_OPTIONS_NATIVE}
 -ffreestanding
-)
\ No newline at end of file
+)

diff  --git a/libcxx/benchmarks/algorithms.bench.cpp 
b/libcxx/benchmarks/algorithms.bench.cpp
index 93383e2b9cd6a..564d89d659cb0 100644
--- a/libcxx/benchmarks/algorithms.bench.cpp
+++ b/libcxx/benchmarks/algorithms.bench.cpp
@@ -334,4 +334,4 @@ int main(int argc, char** argv) {
   makeCartesianProductBenchmark(Quantities);
   makeCartesianProductBenchmark(Quantities);
   benchmark::RunSpecifiedBenchmarks();
-}
\ No newline at end of file
+}

diff  --git a/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h 
b/lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
index 1d67505d736ec..f4017fb663840 100644
--- 

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

2021-10-23 Thread Raphael Isemann via Phabricator via lldb-commits
teemperor requested changes to this revision.
teemperor added a comment.
This revision now requires changes to proceed.

Thanks! This is looking pretty good, I just have some final minor comments 
about some code that I think we can also drop/split-out.




Comment at: lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp:20
 
-class BitsetFrontEnd : public SyntheticChildrenFrontEnd {
+// This class can be used for handling bitsets from both libcxx and libstdcpp.
+class GenericBitsetFrontEnd : public SyntheticChildrenFrontEnd {

nit: `///` to make this into a proper doc string.



Comment at: lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp:23
 public:
-  BitsetFrontEnd(ValueObject );
+  enum class StdLib {
+LibCxx,

I like it!



Comment at: lldb/source/Plugins/Language/CPlusPlus/GenericBitset.cpp:90
+  // template argument.
+  ValueObjectSP dereferenced_type = m_backend.GetSP();
+  if (m_backend.GetCompilerType().IsPointerOrReferenceType()) {

If you look in `CPlusPlusLanguage.cpp` there is a thing called 
`stl_deref_flags` and you can just use the same two lines that define that 
variable in the Libstdc++ init function. The 
`stl_deref_flags.SetFrontEndWantsDereference();` will set a flag that does this 
whole deref-stuff here automatically (that's why this code wasn't necessary for 
the libc++ provider).



Comment at: 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/bitset/TestDataFormatterGenericBitset.py:66
+self.check("ptr", 13)
+self.expect("p ref",
+substrs=['[0] = false',

is there a specific reason for these added `self.expect("p ...", substrs=[])` checks? I think testing the formatter with the expression evaluator 
is good, but there are far less verbose ways to test this (to be specific, 
`self.primes` could be a list of ValueCheck objects and you can pass that same 
ValueObject list as the `result_children`/`children` parameters to 
`self.expect_expr` or `self.expect_var_path`. This could be done in `check` so 
it would also cover all the checks in this test.).

So I would suggest we drop the added checks here and instead leave this up to a 
separate commit that refactors the test (you can do that if you want, but I 
don't mind doing it myself). This commit is in the current state just 
repurposing the existing libcxx formatter (with all the potentially existing 
bugs), so I think this is good enough for landing without expanding the test. 
Otherwise I think these checks could be implemented in a better way with the 
ValueCheck approach (see above).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112180

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


[Lldb-commits] [lldb] ea9e9d6 - [lldb] [Host/SerialPort] Fix build with GCC 7

2021-10-23 Thread Martin Storsjö via lldb-commits

Author: Martin Storsjö
Date: 2021-10-23T12:52:55+03:00
New Revision: ea9e9d61b521adaaa2d7f03712f9f6b9e9dfe8a1

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

LOG: [lldb] [Host/SerialPort] Fix build with GCC 7

Added: 


Modified: 
lldb/source/Host/common/File.cpp

Removed: 




diff  --git a/lldb/source/Host/common/File.cpp 
b/lldb/source/Host/common/File.cpp
index 5ad5ae6bb2192..27a47cab78925 100644
--- a/lldb/source/Host/common/File.cpp
+++ b/lldb/source/Host/common/File.cpp
@@ -837,7 +837,7 @@ SerialPort::Create(int fd, OpenOptions options, Options 
serial_options,
   return std::move(error);
   }
 
-  return out;
+  return std::move(out);
 }
 
 SerialPort::SerialPort(int fd, OpenOptions options,



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


[Lldb-commits] [lldb] ff56d80 - [lldb] [Host/FreeBSD] Remove unused variable (NFC)

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

Author: Michał Górny
Date: 2021-10-23T11:38:35+02:00
New Revision: ff56d80eaa5ea59801843a39be4c65887dbb8b71

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

LOG: [lldb] [Host/FreeBSD] Remove unused variable (NFC)

Added: 


Modified: 
lldb/source/Host/freebsd/HostInfoFreeBSD.cpp

Removed: 




diff  --git a/lldb/source/Host/freebsd/HostInfoFreeBSD.cpp 
b/lldb/source/Host/freebsd/HostInfoFreeBSD.cpp
index 22af5bda66108..50f43999f369b 100644
--- a/lldb/source/Host/freebsd/HostInfoFreeBSD.cpp
+++ b/lldb/source/Host/freebsd/HostInfoFreeBSD.cpp
@@ -32,7 +32,6 @@ llvm::VersionTuple HostInfoFreeBSD::GetOSVersion() {
 
 llvm::Optional HostInfoFreeBSD::GetOSBuildString() {
   int mib[2] = {CTL_KERN, KERN_OSREV};
-  char osrev_str[12];
   uint32_t osrev = 0;
   size_t osrev_len = sizeof(osrev);
 



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


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

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

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


https://reviews.llvm.org/D112357

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

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

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

2021-10-23 Thread Sylvestre Ledru via Phabricator via lldb-commits
sylvestre.ledru added a comment.

> Maybe it would be better to disable the binary completely (in cmake) for 
> unsupported architectures instead?

+1, having an error message like "lldb isn't supported on arch foo" would save 
hours of work :)


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

https://reviews.llvm.org/D102872

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