[Lldb-commits] [lldb] [lldb] Fix module name tab completion (PR #93458)

2024-05-27 Thread Pavel Labath via lldb-commits

https://github.com/labath created 
https://github.com/llvm/llvm-project/pull/93458

Module names can be matched either by a full path or just their basename. The 
completion machinery tried to do both, but had several bugs:
- it always inserted the basename as a completion candidate, even if the string 
being completed was a full path
- due to FileSpec canonicalization, it lost information about trailing slashes 
(it treated "lib/" as "lib", even though it's clear the former was 
trying to complete a directory name)
- due to both of the previous issues, the completion candidates could end up 
being shorter than the string being completed, which caused crashes (string out 
of range errors) when attempting to substitute the results.

This patch rewrites to logic to remove these kinds of issues:
- basename and full path completion are handled separately
- full path completion is attempted always, basename only if the input string 
does not contain a slash
- the code remembers both the canonical and original spelling or the completed 
argument. The canonical arg is used for matching, while the original spelling 
is used for completion. This way "/foo///.//b" can still match "/foo/bar", 
but it will complete to "/foo///.//bar".

>From aca5ab852854a46ba5443864c555d5479956d05d Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Mon, 27 May 2024 11:02:56 +
Subject: [PATCH] [lldb] Fix module name tab completion

Module names can be matched either by a full path or just their
basename. The completion machinery tried to do both, but had several
bugs:
- it always inserted the basename as a completion candidate, even if the
  string being completed was a full path
- due to FileSpec canonicalization, it lost information about trailing
  slashes (it treated "lib/" as "lib", even though it's clear
  the former was trying to complete a directory name)
- due to both of the previous issues, the completion candidates could
  end up being shorter than the string being completed, which caused
  crashes (string out of range errors) when attempting to substitute the
  results.

This patch rewrites to logic to remove these kinds of issues:
- basename and full path completion are handled separately
- full path completion is attempted always, basename only if the input
  string does not contain a slash
- the code remembers both the canonical and original spelling or the
  completed argument. The canonical arg is used for matching, while the
  original spelling is used for completion. This way "/foo///.//b"
  can still match "/foo/bar", but it will complete to "/foo///.//bar".
---
 lldb/source/Commands/CommandCompletions.cpp   | 58 ---
 .../completion/TestCompletion.py  | 35 +++
 2 files changed, 72 insertions(+), 21 deletions(-)

diff --git a/lldb/source/Commands/CommandCompletions.cpp 
b/lldb/source/Commands/CommandCompletions.cpp
index 16078a92ab5fe..baa9dda1f68e6 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -6,7 +6,9 @@
 //
 
//===--===//
 
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 
 #include "lldb/Breakpoint/Watchpoint.h"
@@ -262,9 +264,26 @@ class ModuleCompleter : public Completer {
 public:
   ModuleCompleter(CommandInterpreter &interpreter, CompletionRequest &request)
   : Completer(interpreter, request) {
-FileSpec partial_spec(m_request.GetCursorArgumentPrefix());
-m_file_name = partial_spec.GetFilename().GetCString();
-m_dir_name = partial_spec.GetDirectory().GetCString();
+llvm::StringRef request_str = m_request.GetCursorArgumentPrefix();
+// We can match the full path, or the file name only. The full match will 
be
+// attempted always, the file name match only if the request does not
+// contain a path separator.
+
+// Preserve both the path as spelled by the user (used for completion) and
+// the canonical version (used for matching).
+m_spelled_path = request_str;
+m_canonical_path = FileSpec(m_spelled_path).GetPath();
+if (!m_spelled_path.empty() &&
+llvm::sys::path::is_separator(m_spelled_path.back()) &&
+!llvm::StringRef(m_canonical_path).ends_with(m_spelled_path.back())) {
+  m_canonical_path += m_spelled_path.back();
+}
+
+bool has_separator = llvm::find_if(request_str, [](char c) {
+   return llvm::sys::path::is_separator(c);
+ }) != request_str.end();
+m_file_name =
+has_separator ? llvm::sys::path::get_separator() : request_str;
   }
 
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
@@ -273,22 +292,18 @@ class ModuleCompleter : public Completer {
   SymbolContext &context,
   Address *addr) override {
 

[Lldb-commits] [lldb] [lldb] Fix module name tab completion (PR #93458)

2024-05-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

Module names can be matched either by a full path or just their basename. The 
completion machinery tried to do both, but had several bugs:
- it always inserted the basename as a completion candidate, even if the string 
being completed was a full path
- due to FileSpec canonicalization, it lost information about trailing slashes 
(it treated "lib/" as "lib", even though it's clear the 
former was trying to complete a directory name)
- due to both of the previous issues, the completion candidates could end up 
being shorter than the string being completed, which caused crashes (string out 
of range errors) when attempting to substitute the results.

This patch rewrites to logic to remove these kinds of issues:
- basename and full path completion are handled separately
- full path completion is attempted always, basename only if the input string 
does not contain a slash
- the code remembers both the canonical and original spelling or the completed 
argument. The canonical arg is used for matching, while the original spelling 
is used for completion. This way "/foo///.//b" can still match 
"/foo/bar", but it will complete to "/foo///.//bar".

---
Full diff: https://github.com/llvm/llvm-project/pull/93458.diff


2 Files Affected:

- (modified) lldb/source/Commands/CommandCompletions.cpp (+37-21) 
- (modified) lldb/test/API/functionalities/completion/TestCompletion.py (+35) 


``diff
diff --git a/lldb/source/Commands/CommandCompletions.cpp 
b/lldb/source/Commands/CommandCompletions.cpp
index 16078a92ab5fe..baa9dda1f68e6 100644
--- a/lldb/source/Commands/CommandCompletions.cpp
+++ b/lldb/source/Commands/CommandCompletions.cpp
@@ -6,7 +6,9 @@
 //
 
//===--===//
 
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 
 #include "lldb/Breakpoint/Watchpoint.h"
@@ -262,9 +264,26 @@ class ModuleCompleter : public Completer {
 public:
   ModuleCompleter(CommandInterpreter &interpreter, CompletionRequest &request)
   : Completer(interpreter, request) {
-FileSpec partial_spec(m_request.GetCursorArgumentPrefix());
-m_file_name = partial_spec.GetFilename().GetCString();
-m_dir_name = partial_spec.GetDirectory().GetCString();
+llvm::StringRef request_str = m_request.GetCursorArgumentPrefix();
+// We can match the full path, or the file name only. The full match will 
be
+// attempted always, the file name match only if the request does not
+// contain a path separator.
+
+// Preserve both the path as spelled by the user (used for completion) and
+// the canonical version (used for matching).
+m_spelled_path = request_str;
+m_canonical_path = FileSpec(m_spelled_path).GetPath();
+if (!m_spelled_path.empty() &&
+llvm::sys::path::is_separator(m_spelled_path.back()) &&
+!llvm::StringRef(m_canonical_path).ends_with(m_spelled_path.back())) {
+  m_canonical_path += m_spelled_path.back();
+}
+
+bool has_separator = llvm::find_if(request_str, [](char c) {
+   return llvm::sys::path::is_separator(c);
+ }) != request_str.end();
+m_file_name =
+has_separator ? llvm::sys::path::get_separator() : request_str;
   }
 
   lldb::SearchDepth GetDepth() override { return lldb::eSearchDepthModule; }
@@ -273,22 +292,18 @@ class ModuleCompleter : public Completer {
   SymbolContext &context,
   Address *addr) override {
 if (context.module_sp) {
-  const char *cur_file_name =
-  context.module_sp->GetFileSpec().GetFilename().GetCString();
-  const char *cur_dir_name =
-  context.module_sp->GetFileSpec().GetDirectory().GetCString();
-
-  bool match = false;
-  if (m_file_name && cur_file_name &&
-  strstr(cur_file_name, m_file_name) == cur_file_name)
-match = true;
-
-  if (match && m_dir_name && cur_dir_name &&
-  strstr(cur_dir_name, m_dir_name) != cur_dir_name)
-match = false;
-
-  if (match) {
-m_request.AddCompletion(cur_file_name);
+  // Attempt a full path match.
+  std::string cur_path = context.module_sp->GetFileSpec().GetPath();
+  llvm::StringRef cur_path_view = cur_path;
+  if (cur_path_view.consume_front(m_canonical_path))
+m_request.AddCompletion((m_spelled_path + cur_path_view).str());
+
+  // And a file name match.
+  if (m_file_name) {
+llvm::StringRef cur_file_name =
+context.module_sp->GetFileSpec().GetFilename().GetStringRef();
+if (cur_file_name.starts_with(*m_file_name))
+  m_request.AddCompletion(cur_file_name);
   }
 }
 return Searcher::eCallbackReturnContinue;
@@ -297,8 +312,9 @@ class Modu

[Lldb-commits] [lldb] [lldb] Fix module name tab completion (PR #93458)

2024-05-27 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
80b78f5fb30c43cd88f0d096081bc7f1509b0110...aca5ab852854a46ba5443864c555d5479956d05d
 lldb/test/API/functionalities/completion/TestCompletion.py
``





View the diff from darker here.


``diff
--- TestCompletion.py   2024-05-27 11:22:26.00 +
+++ TestCompletion.py   2024-05-27 11:27:41.326501 +
@@ -914,18 +914,18 @@
 self.registerSharedLibrariesWithTarget(target, ["shared"])
 
 basenames = []
 paths = []
 for m in target.modules:
-  basenames.append(m.file.basename)
-  paths.append(m.file.fullpath)
+basenames.append(m.file.basename)
+paths.append(m.file.fullpath)
 
 # To see all the diffs
 self.maxDiff = None
 
 # An empty string completes to everything
-self.completions_match("target symbols add -s ", basenames+paths)
+self.completions_match("target symbols add -s ", basenames + paths)
 
 # Base name completion
 self.completions_match("target symbols add -s a.", ["a.out"])
 
 # Full path completion
@@ -937,7 +937,7 @@
 self.completions_match("target symbols add -s '" + prefix_sep, paths)
 
 # The completed path should match the spelling of the input, so if the
 # input contains a double separator, so should the completions.
 prefix_sep_sep = prefix_sep + os.path.sep
-paths_sep = [ prefix_sep_sep +p[len(prefix_sep):] for p in paths]
+paths_sep = [prefix_sep_sep + p[len(prefix_sep) :] for p in paths]
 self.completions_match("target symbols add -s '" + prefix_sep_sep, 
paths_sep)

``




https://github.com/llvm/llvm-project/pull/93458
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][riscv] Fix setting breakpoint for undecoded instruction (PR #90075)

2024-05-27 Thread via lldb-commits


@@ -115,8 +148,23 @@ Status 
NativeProcessSoftwareSingleStep::SetupSoftwareSingleStepping(
   emulator_up->SetWriteMemCallback(&WriteMemoryCallback);
   emulator_up->SetWriteRegCallback(&WriteRegisterCallback);
 
-  if (!emulator_up->ReadInstruction())
-return Status("Read instruction failed!");
+  if (!emulator_up->ReadInstruction()) {

ita-sc wrote:

Yep, you are right: I'm adding an interface to get instruction size, as if it 
is not a jump or branch, actually, we do not need to emulate it on engine. As 
RISCV have a lot of extensions, even vendor-specific, we can not simply emulate 
all of them. I've added a common interface, as it may be helpful for other 
architectures, as for new implementations later user will need to implement 
only branches and jumps.

https://github.com/llvm/llvm-project/pull/90075
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][riscv] Fix setting breakpoint for undecoded instruction (PR #90075)

2024-05-27 Thread via lldb-commits

https://github.com/ita-sc updated 
https://github.com/llvm/llvm-project/pull/90075

>From a95314eb8afd5f697a7a138d4e1e1465611c8533 Mon Sep 17 00:00:00 2001
From: Ivan Tetyushkin 
Date: Fri, 19 Apr 2024 18:47:05 +0300
Subject: [PATCH 1/2] [lldb][riscv] Fix setting breakpoint for undecoded
 instruction

Copy gdb behaviour:
For RISCV we can set breakpoint even for unknown instruction, as
RISCV encoding have information about size of instruction.
---
 .../RISCV/EmulateInstructionRISCV.cpp | 23 +-
 .../RISCV/EmulateInstructionRISCV.h   |  3 +
 .../NativeProcessSoftwareSingleStep.cpp   | 78 ---
 3 files changed, 75 insertions(+), 29 deletions(-)

diff --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp 
b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
index 6c46618b337c2..3f61e011d620a 100644
--- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
+++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
@@ -624,9 +624,26 @@ std::optional 
EmulateInstructionRISCV::Decode(uint32_t inst) {
   uint16_t try_rvc = uint16_t(inst & 0x);
   // check whether the compressed encode could be valid
   uint16_t mask = try_rvc & 0b11;
-  bool is_rvc = try_rvc != 0 && mask != 3;
   uint8_t inst_type = RV64;
 
+  // Try to get size of RISCV instruction.
+  // 1.2 Instruction Length Encoding
+  bool is_16b = (inst & 0b11) != 0b11;
+  bool is_32b = (inst & 0x1f) != 0x1f;
+  bool is_48b = (inst & 0x3f) != 0x1f;
+  bool is_64b = (inst & 0x7f) != 0x3f;
+  if (is_16b)
+m_last_size = 2;
+  else if (is_32b)
+m_last_size = 4;
+  else if (is_48b)
+m_last_size = 6;
+  else if (is_64b)
+m_last_size = 8;
+  else
+// Not Valid
+m_last_size = std::nullopt;
+
   // if we have ArchSpec::eCore_riscv128 in the future,
   // we also need to check it here
   if (m_arch.GetCore() == ArchSpec::eCore_riscv32)
@@ -638,8 +655,8 @@ std::optional 
EmulateInstructionRISCV::Decode(uint32_t inst) {
   LLDB_LOGF(
   log, "EmulateInstructionRISCV::%s: inst(%x at %" PRIx64 ") was 
decoded to %s",
   __FUNCTION__, inst, m_addr, pat.name);
-  auto decoded = is_rvc ? pat.decode(try_rvc) : pat.decode(inst);
-  return DecodeResult{decoded, inst, is_rvc, pat};
+  auto decoded = is_16b ? pat.decode(try_rvc) : pat.decode(inst);
+  return DecodeResult{decoded, inst, is_16b, pat};
 }
   }
   LLDB_LOGF(log, "EmulateInstructionRISCV::%s: inst(0x%x) was unsupported",
diff --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h 
b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h
index 8bca73a7f589d..4e103f14a5894 100644
--- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h
+++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h
@@ -60,6 +60,7 @@ class EmulateInstructionRISCV : public EmulateInstruction {
 
   bool SetTargetTriple(const ArchSpec &arch) override;
   bool ReadInstruction() override;
+  virtual std::optional GetLastInstrSize() { return std::nullopt; }
   bool EvaluateInstruction(uint32_t options) override;
   bool TestEmulation(Stream &out_stream, ArchSpec &arch,
  OptionValueDictionary *test_data) override;
@@ -99,6 +100,8 @@ class EmulateInstructionRISCV : public EmulateInstruction {
 private:
   /// Last decoded instruction from m_opcode
   DecodeResult m_decoded;
+  /// Last decoded instruction size estimate.
+  std::optional m_last_size;
 };
 
 } // namespace lldb_private
diff --git 
a/lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp 
b/lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp
index 6bf8a0dc28b22..a6019d0973747 100644
--- a/lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp
+++ b/lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp
@@ -94,6 +94,39 @@ static lldb::addr_t ReadFlags(NativeRegisterContext 
®siter_context) {
  LLDB_INVALID_ADDRESS);
 }
 
+static int GetSoftwareWatchpointSize(const ArchSpec &arch,
+ lldb::addr_t next_flags) {
+  if (arch.GetMachine() == llvm::Triple::arm) {
+if (next_flags & 0x20)
+  // Thumb mode
+  return 2;
+else
+  // Arm mode
+  return 4;
+  }
+  if (arch.IsMIPS() || arch.GetTriple().isPPC64() ||
+  arch.GetTriple().isRISCV() || arch.GetTriple().isLoongArch())
+return 4;
+  return 0;
+}
+
+static Status SetSoftwareBreakPointOnPC(const ArchSpec &arch, lldb::addr_t pc,
+lldb::addr_t next_flags,
+NativeProcessProtocol &process) {
+  int size_hint = GetSoftwareWatchpointSize(arch, next_flags);
+  Status error;
+  error = process.SetBreakpoint(pc, size_hint, /*hardware=*/false);
+
+  // If setting the breakpoint fails because pc is out of the address
+  // space, ignore it and let the d

[Lldb-commits] [lldb] [lldb][riscv] Fix setting breakpoint for undecoded instruction (PR #90075)

2024-05-27 Thread via lldb-commits


@@ -115,8 +148,23 @@ Status 
NativeProcessSoftwareSingleStep::SetupSoftwareSingleStepping(
   emulator_up->SetWriteMemCallback(&WriteMemoryCallback);
   emulator_up->SetWriteRegCallback(&WriteRegisterCallback);
 
-  if (!emulator_up->ReadInstruction())
-return Status("Read instruction failed!");
+  if (!emulator_up->ReadInstruction()) {
+// try to get at least the size of next instruction to set breakpoint.
+auto instrSizeOpt = emulator_up->GetLastInstrSize();
+if (!instrSizeOpt)
+  return Status("Read instruction failed!");

ita-sc wrote:

Well, in this MR this is a common code, and every other architecture now not 
implemented `GetLastInstrSize`, so it will fail with the same error, as it was 
before. For RISC-V we will generate the same error if we can not get the size 
of instruction (if we can not read memory or if an instruction is bigger than 
expected)

https://github.com/llvm/llvm-project/pull/90075
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][riscv] Fix setting breakpoint for undecoded instruction (PR #90075)

2024-05-27 Thread via lldb-commits


@@ -115,8 +148,23 @@ Status 
NativeProcessSoftwareSingleStep::SetupSoftwareSingleStepping(
   emulator_up->SetWriteMemCallback(&WriteMemoryCallback);
   emulator_up->SetWriteRegCallback(&WriteRegisterCallback);
 
-  if (!emulator_up->ReadInstruction())
-return Status("Read instruction failed!");
+  if (!emulator_up->ReadInstruction()) {
+// try to get at least the size of next instruction to set breakpoint.
+auto instrSizeOpt = emulator_up->GetLastInstrSize();
+if (!instrSizeOpt)
+  return Status("Read instruction failed!");
+bool success = false;
+auto pc = emulator_up->ReadRegisterUnsigned(eRegisterKindGeneric,
+LLDB_REGNUM_GENERIC_PC,
+LLDB_INVALID_ADDRESS, 
&success);
+if (!success)
+  return Status("Reading pc failed!");
+lldb::addr_t next_pc = pc + *instrSizeOpt;
+auto Result =
+SetSoftwareBreakPointOnPC(arch, next_pc, /* next_flags */ 0x0, 
process);

ita-sc wrote:

Actually, I do not understand fully what you mean. For RISCV software 
breakpoint size is 4 or 2 (currently LLDB hardcodes only 4). We save memory and 
restore it later, so it seems we will have no problems here for different 
instruction sizes on memory regions where we write software breakpoint.

https://github.com/llvm/llvm-project/pull/90075
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][riscv] Fix setting breakpoint for undecoded instruction (PR #90075)

2024-05-27 Thread via lldb-commits


@@ -99,6 +100,8 @@ class EmulateInstructionRISCV : public EmulateInstruction {
 private:
   /// Last decoded instruction from m_opcode
   DecodeResult m_decoded;
+  /// Last tried to be decoded instruction expected size.

ita-sc wrote:

Well, I tried to emphasize that even if we failed to fully decode instruction, 
we are still able to fill this information. I'll change to 
```
Last decoded instruction size estimate.
```

https://github.com/llvm/llvm-project/pull/90075
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][riscv] Fix setting breakpoint for undecoded instruction (PR #90075)

2024-05-27 Thread via lldb-commits

ita-sc wrote:

> I read this patch while trying to keep the RVC instruction set in mind 
> because it's an interesting case to consider. Maybe the test file could have 
> a compressed instruction? The one instruction there now ends in 0b11 so I 
> don't think it will decode that way.

The test intentionally has an invalid instruction. I'll add one more test with 
compressed illegal instruction.
In current test it seems it is decoded as some 4-size instruction, as expected: 
https://godbolt.org/z/bMPf7faWW
```
addis0,sp,16
 .4byte 0xc58573
```


https://github.com/llvm/llvm-project/pull/90075
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [clang] [compiler-rt] [lldb] [llvm] [Support] Remove terminfo dependency (PR #92865)

2024-05-27 Thread Aaron Siddhartha Mondal via lldb-commits

aaronmondal wrote:

@gulfemsavrun The file `terminal.c` that is causing this linker error is not in 
LLVM but in `libedit`. The configure step doesn't find `libedit`:

```
Not searching for unused variables given on the command line.
-- Could NOT find LibEdit (missing: LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES) 
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) 
-- Could NOT find zstd (missing: zstd_LIBRARY zstd_INCLUDE_DIR) 
-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) 
-- Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR) 

...

-- Could NOT find LibEdit (missing: LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES) 
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) 
-- Could NOT find zstd (missing: zstd_LIBRARY zstd_INCLUDE_DIR) 
-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) 
-- Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR) 

...

-- Building with -fPIC
-- LLVM host triple: x86_64-unknown-linux-gnu
-- LLVM default target triple: x86_64-unknown-linux-gnu
-- Using libunwind testing configuration: 
/b/s/w/ir/x/w/llvm-llvm-project/libunwind/test/configs/llvm-libunwind-static.cfg.in
-- Failed to locate sphinx-build executable (missing: SPHINX_EXECUTABLE) 
-- Using libc++abi testing configuration: 
/b/s/w/ir/x/w/llvm-llvm-project/libcxxabi/test/configs/llvm-libc++abi-static.cfg.in
-- Using libc++ testing configuration: 
/b/s/w/ir/x/w/llvm-llvm-project/libcxx/test/configs/llvm-libc++-static.cfg.in
-- Could NOT find LibEdit (missing: LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES) 
-- Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR) 
-- Could NOT find zstd (missing: zstd_LIBRARY zstd_INCLUDE_DIR) 
-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) 
```

My guess is that some other mechanism is adding `libedit` into this build with 
an explicit `-ledit` flag instead of using `pkgconfig`. This causing the 
`/usr/lib64/pkgconfig/libedit.pc` (or similar) file to be ignored. That file 
should contain a line like `Libs.private: -ltinfo` if it's a `libedit` that was 
configured to depend on `tinfo`.

```
FAILED: unittests/LineEditor/LineEditorTests 
: && /b/s/w/ir/x/w/cipd/bin/clang++ --sysroot=/b/s/w/ir/x/w/cipd/linux 
-stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -ffat-lto-objects 
-ffile-prefix-map=/b/s/w/ir/x/w/llvm_build=../llvm-llvm-project 
-ffile-prefix-map=/b/s/w/ir/x/w/llvm-llvm-project/= -no-canonical-prefixes -O3 
-DNDEBUG -static-libstdc++ -stdlib=libc++ -static-libstdc++ -fuse-ld=lld 
-Wl,--color-diagnostics -ffat-lto-objects-Wl,--gc-sections 
unittests/LineEditor/CMakeFiles/LineEditorTests.dir/LineEditor.cpp.o -o 
unittests/LineEditor/LineEditorTests  lib/libLLVMLineEditor.a  
lib/libLLVMSupport.a  lib/libLLVMSupport.a  -lpthread  lib/libllvm_gtest_main.a 
 lib/libllvm_gtest.a  -lpthread  /b/s/w/ir/x/w/libedit_install/lib/libedit.a  
lib/libLLVMSupport.a  -lrt  -ldl  -lpthread  -lm  
/b/s/w/ir/x/w/zlib_install_target/lib/libz.a  
/b/s/w/ir/x/w/zstd_install/lib/libzstd.a  -pthread  lib/libLLVMDemangle.a  
-lpthread && :
ld.lld: error: undefined symbol: tgetent
>>> referenced by terminal.c
>>>   terminal.o:(terminal_set) in archive 
>>> /b/s/w/ir/x/w/libedit_install/lib/libedit.a

ld.lld: error: undefined symbol: tgetflag
>>> referenced by terminal.c
>>>   terminal.o:(terminal_set) in archive 
>>> /b/s/w/ir/x/w/libedit_install/lib/libedit.a
>>> referenced by terminal.c
>>>   terminal.o:(terminal_set) in archive 
>>> /b/s/w/ir/x/w/libedit_install/lib/libedit.a
>>> referenced by terminal.c
>>>   terminal.o:(terminal_set) in archive 
>>> /b/s/w/ir/x/w/libedit_install/lib/libedit.a
>>> referenced 3 more times

ld.lld: error: undefined symbol: tgetnum
>>> referenced by terminal.c
>>>   terminal.o:(terminal_set) in archive 
>>> /b/s/w/ir/x/w/libedit_install/lib/libedit.a
>>> referenced by terminal.c
>>>   terminal.o:(terminal_set) in archive 
>>> /b/s/w/ir/x/w/libedit_install/lib/libedit.a

ld.lld: error: undefined symbol: tgetstr
>>> referenced by terminal.c
>>>   terminal.o:(terminal_set) in archive 
>>> /b/s/w/ir/x/w/libedit_install/lib/libedit.a
>>> referenced by terminal.c
>>>   terminal.o:(terminal_echotc) in archive 
>>> /b/s/w/ir/x/w/libedit_install/lib/libedit.a

ld.lld: error: undefined symbol: tputs
>>> referenced by terminal.c
>>>   terminal.o:(terminal_move_to_line) in archive

[Lldb-commits] [clang] [compiler-rt] [lldb] [llvm] [Support] Remove terminfo dependency (PR #92865)

2024-05-27 Thread via lldb-commits

gulfemsavrun wrote:

Ok, thanks for your analysis @aaronmondal!  

https://github.com/llvm/llvm-project/pull/92865
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] Add a createError variant without error code (NFC) (PR #93209)

2024-05-27 Thread Lang Hames via lldb-commits

lhames wrote:

Late to the party here, but some context might be of interest:

`inconvertibleErrorCode` was meant to never be used, except with a documented 
explanation of why no error code could be supplied. The idea was to make 
conversion between `Error` and `std::error_code` illegal when no error code was 
supplied.

In practice (1) nobody has adhered to the documentation rule (me included), and 
(2) nobody seems to be converting errors back into std::error_codes in a 
dangerous way*. At this point I'd be fine getting rid of 
`inconvertibleErrorCode` entirely and replacing it with an "unknownErrorCode" 
that could be used as a default instead.

* There is some danger that people _have_ tried such invalid conversions and 
either caught the issue before submitting, or have never hit the dangerous path 
at runtime and don't realize it's there. If we switched to a safe 
"unknownErrorCode" we would lose some signal on the former (it'd be an error 
report rather than a crash), but would prevent the latter from happening in 
production.

https://github.com/llvm/llvm-project/pull/93209
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits