[Lldb-commits] [lldb] Reapply "[lldb/aarch64] Fix unwinding when signal interrupts a leaf f… (PR #92503)

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

labath wrote:

I'm not quite sure what you have in mind, but I can tell you what's been going 
through my mind in the context of the `m_all_registers_available` check in 
`lldb/source/Target/RegisterContextUnwind.cpp` . The way I see it, this check 
(at least the part about the RA register(*)) is heuristic that's impossible to 
get always right. Like, I could construct a test case using functions with 
non-standard ABIs where a non-leaf function legitimately has a `lr=` 
rule. Such code would execute correctly but lldb would refuse to unwind it due 
to the `lr=` restriction.

The only thing needed to construct such a test case is one (possibly leaf) 
function, which "returns" to a register other than `lr` (it could even return 
to a memory address). Then, its caller could "call" that function by storing 
the return address to some other place, and leaving it's own return address 
register (i.e, `lr`) untouched. (I don't know why anyone would do such a thing, 
since it would likely mess up the CPUs branch predictor, but dwarf is perfectly 
capable of expressing code like this)

Another interesting case is that of a function (an abi-respecting function this 
time), which chooses to save the `lr` to a different (non-volatile) register, 
instead of the usual stack location. This function could then call other 
functions as usual, but we wouldn't be able to unwind from it in a single step 
-- to get its value of `lr` (i.e., the `pc` of the frame *above* it), we would 
need to find where has the frame *below* stored the register that `lr` was 
saved to. (I also don't know of anyone writing code like this, but unlike the 
previous case, I can imagine some very specific situations where such an 
optimization might be profitable.)

All of this is to say that I don't think there is a way to change this piece of 
code to be correct all the time -- we'd just be trading one set of edge cases 
for the other. I think that the most correct solution would be to remove this 
check altogether. I'm not sure why it exists, but I expect it has something to 
do with preventing looping stacks. However, if I remember correctly, we already 
have some checks to prevent stack loops (if not, then we should have, as there 
are other ways to create stack loops), so I think it should be possible to let 
the `lr=` (*) rule through here and catch erroneous cases further down 
the road. However, I also don't have any plans to pursue this direction.

(*) I'm only talking about the `lr` rule everywhere. I *think* that a 
`pc=` rule would always be an error (even in signal handlers), so we 
should be able to keep that here. OTOH, if our loop detection code is robust 
enough, then there should be no harm in letting this through either...

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


[Lldb-commits] [lldb] [lldb/DWARF] Make sure bad abbreviation codes do not crash lldb (PR #93006)

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

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

We currently cannot represent abbreviation codes with more than 16 bits, and we 
were lldb-asserting if we ever ran into one. While I haven't seen any real 
DWARF with these kinds of abbreviations, it is possible to hit this with 
handcrafted evil dwarf, due some sort of corruptions, or just bugs (the 
addition of PeekDIEName makes these bugs more likely, as the function blindly 
dereferences offsets within the debug info section) .

Missing abbreviations were already reporting an error. This patch turns sure 
that large abbreviations into an error as well, and adds a test for both cases.

>From 03ab6febc0f40d0f39f533a5b4fd7c33a6728ae1 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 21 May 2024 15:31:23 +
Subject: [PATCH] [lldb/DWARF] Make sure bad abbreviation codes do not crash
 lldb

We currently cannot represent abbreviation codes with more than 16 bits,
and we were lldb-asserting if we ever ran into one. While I haven't seen
any real DWARF with these kinds of abbreviations, it is possible to hit
this with handcrafted evil dwarf, due some sort of corruptions, or just
bugs (the addition of PeekDIEName makes these bugs more likely, as the
function blindly dereferences offsets within the debug info section) .

Missing abbreviations were already reporting an error. This patch turns
sure that large abbreviations into an error as well, and adds a test for
both cases.
---
 .../SymbolFile/DWARF/DWARFDebugInfoEntry.cpp  | 34 +++---
 .../DWARF/x86/invalid_abbreviation.s  | 47 +++
 2 files changed, 63 insertions(+), 18 deletions(-)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/invalid_abbreviation.s

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 1b0fefedf9836..4357ccb2f5c9f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -11,6 +11,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 #include "llvm/Support/LEB128.h"
@@ -44,10 +45,20 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor 
&data,
   const DWARFUnit *cu,
   lldb::offset_t *offset_ptr) {
   m_offset = *offset_ptr;
+  auto report_error = [&](const char *fmt, const auto &...vals) {
+cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
+"[{0:x16}]: {1}, please file a bug and "
+"attach the file at the start of this error message",
+static_cast(m_offset), llvm::formatv(fmt, vals...));
+*offset_ptr = std::numeric_limits::max();
+return false;
+  };
+
   m_parent_idx = 0;
   m_sibling_idx = 0;
   const uint64_t abbr_idx = data.GetULEB128(offset_ptr);
-  lldbassert(abbr_idx <= UINT16_MAX);
+  if (abbr_idx > std::numeric_limits::max())
+return report_error("abbreviation code {0} too big", abbr_idx);
   m_abbr_idx = abbr_idx;
 
   if (m_abbr_idx == 0) {
@@ -57,16 +68,9 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor 
&data,
   }
 
   const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
-  if (abbrevDecl == nullptr) {
-cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-"[{0:x16}]: invalid abbreviation code {1}, "
-"please file a bug and "
-"attach the file at the start of this error message",
-(uint64_t)m_offset, (unsigned)abbr_idx);
-// WE can't parse anymore if the DWARF is borked...
-*offset_ptr = UINT32_MAX;
-return false;
-  }
+  if (abbrevDecl == nullptr)
+return report_error("invalid abbreviation code {0}", abbr_idx);
+
   m_tag = abbrevDecl->getTag();
   m_has_children = abbrevDecl->hasChildren();
   // Skip all data in the .debug_info or .debug_types for the attributes
@@ -74,13 +78,7 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor 
&data,
 if (DWARFFormValue::SkipValue(attribute.Form, data, offset_ptr, cu))
   continue;
 
-cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-"[{0:x16}]: Unsupported DW_FORM_{1:x}, please file a bug "
-"and "
-"attach the file at the start of this error message",
-(uint64_t)m_offset, (unsigned)attribute.Form);
-*offset_ptr = m_offset;
-return false;
+return report_error("Unsupported DW_FORM_{1:x}", attribute.Form);
   }
   return true;
 }
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/invalid_abbreviation.s 
b/lldb/test/Shell/SymbolFile/DWARF/x86/invalid_abbreviation.s
new file mode 100644
index 0..3f32c037aeb20
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/invalid_abbreviation.s
@@ -0,0 +1,47 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t
+# RUN: %lldb %t \
+# RUN:   -o exit 2>&1 | FileCheck %s
+
+# CHECK-DAG: error: {{.*}} [0x

[Lldb-commits] [lldb] [lldb/DWARF] Make sure bad abbreviation codes do not crash lldb (PR #93006)

2024-05-22 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

We currently cannot represent abbreviation codes with more than 16 bits, and we 
were lldb-asserting if we ever ran into one. While I haven't seen any real 
DWARF with these kinds of abbreviations, it is possible to hit this with 
handcrafted evil dwarf, due some sort of corruptions, or just bugs (the 
addition of PeekDIEName makes these bugs more likely, as the function blindly 
dereferences offsets within the debug info section) .

Missing abbreviations were already reporting an error. This patch turns sure 
that large abbreviations into an error as well, and adds a test for both cases.

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


2 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp 
(+16-18) 
- (added) lldb/test/Shell/SymbolFile/DWARF/x86/invalid_abbreviation.s (+47) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
index 1b0fefedf9836..4357ccb2f5c9f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
@@ -11,6 +11,7 @@
 #include 
 
 #include 
+#include 
 #include 
 
 #include "llvm/Support/LEB128.h"
@@ -44,10 +45,20 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor 
&data,
   const DWARFUnit *cu,
   lldb::offset_t *offset_ptr) {
   m_offset = *offset_ptr;
+  auto report_error = [&](const char *fmt, const auto &...vals) {
+cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
+"[{0:x16}]: {1}, please file a bug and "
+"attach the file at the start of this error message",
+static_cast(m_offset), llvm::formatv(fmt, vals...));
+*offset_ptr = std::numeric_limits::max();
+return false;
+  };
+
   m_parent_idx = 0;
   m_sibling_idx = 0;
   const uint64_t abbr_idx = data.GetULEB128(offset_ptr);
-  lldbassert(abbr_idx <= UINT16_MAX);
+  if (abbr_idx > std::numeric_limits::max())
+return report_error("abbreviation code {0} too big", abbr_idx);
   m_abbr_idx = abbr_idx;
 
   if (m_abbr_idx == 0) {
@@ -57,16 +68,9 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor 
&data,
   }
 
   const auto *abbrevDecl = GetAbbreviationDeclarationPtr(cu);
-  if (abbrevDecl == nullptr) {
-cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-"[{0:x16}]: invalid abbreviation code {1}, "
-"please file a bug and "
-"attach the file at the start of this error message",
-(uint64_t)m_offset, (unsigned)abbr_idx);
-// WE can't parse anymore if the DWARF is borked...
-*offset_ptr = UINT32_MAX;
-return false;
-  }
+  if (abbrevDecl == nullptr)
+return report_error("invalid abbreviation code {0}", abbr_idx);
+
   m_tag = abbrevDecl->getTag();
   m_has_children = abbrevDecl->hasChildren();
   // Skip all data in the .debug_info or .debug_types for the attributes
@@ -74,13 +78,7 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor 
&data,
 if (DWARFFormValue::SkipValue(attribute.Form, data, offset_ptr, cu))
   continue;
 
-cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-"[{0:x16}]: Unsupported DW_FORM_{1:x}, please file a bug "
-"and "
-"attach the file at the start of this error message",
-(uint64_t)m_offset, (unsigned)attribute.Form);
-*offset_ptr = m_offset;
-return false;
+return report_error("Unsupported DW_FORM_{1:x}", attribute.Form);
   }
   return true;
 }
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/invalid_abbreviation.s 
b/lldb/test/Shell/SymbolFile/DWARF/x86/invalid_abbreviation.s
new file mode 100644
index 0..3f32c037aeb20
--- /dev/null
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/invalid_abbreviation.s
@@ -0,0 +1,47 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t
+# RUN: %lldb %t \
+# RUN:   -o exit 2>&1 | FileCheck %s
+
+# CHECK-DAG: error: {{.*}} [0x0022]: abbreviation code 65536 too 
big, please file a bug and attach the file at the start of this error message
+# CHECK-DAG: error: {{.*}} [0x0048]: invalid abbreviation code 47, 
please file a bug and attach the file at the start of this error message
+
+
+.section.debug_abbrev,"",@progbits
+.uleb128 65535  # Largest representable Abbreviation 
Code
+.byte   17  # DW_TAG_compile_unit
+.byte   1   # DW_CHILDREN_yes
+.byte   37  # DW_AT_producer
+.byte   8   # DW_FORM_string
+.byte   0   # EOM(1)
+.byte   0   # EOM(2)
+.byte   0   # EOM(3)
+
+ 

[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-22 Thread Vlad Serebrennikov via lldb-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/92953

>From 66e05ac24613435dbe774d49684d8ff9d119c4c3 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 21 May 2024 21:41:24 +0300
Subject: [PATCH 1/2] Remove some `try_compile` CMake checks for compiler flags

This patch remove 36 checks for compiler flags that are done via invoking the 
compiler across LLVM, Clang, and LLDB. It's was made possible by raising the 
bar for supported compilers that has been happening over the years since the 
checks were added.

This is going to improve CMake configuration times. This topic was highlighted 
in 
https://discourse.llvm.org/t/cmake-compiler-flag-checks-are-really-slow-ideas-to-speed-them-up/78882.
---
 clang/CMakeLists.txt  |   5 +-
 .../tests/functional/exec/CMakeLists.txt  |   6 +-
 lldb/cmake/modules/LLDBConfig.cmake   |  20 +--
 llvm/cmake/config-ix.cmake|  19 +--
 llvm/cmake/modules/AddLLVM.cmake  |   4 +-
 llvm/cmake/modules/HandleLLVMOptions.cmake| 142 --
 third-party/unittest/CMakeLists.txt   |   4 +-
 7 files changed, 80 insertions(+), 120 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index c20ce47a12abb..a6bcb853a464c 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -349,10 +349,7 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-long-long")
   endif ()
 
-  check_cxx_compiler_flag("-Werror -Wnested-anon-types" 
CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG)
-  if( CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG )
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
-  endif()
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
 endif ()
 
 # Determine HOST_LINK_VERSION on Darwin.
diff --git a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt 
b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
index 95c6fdb610e0f..cb6ebda183725 100644
--- a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
+++ b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
@@ -2,11 +2,7 @@ project(exec C)
 
 cmake_minimum_required(VERSION 3.20.0)
 
-include(CheckCCompilerFlag)
-check_c_compiler_flag("-std=c99" C99_SUPPORTED)
-if (C99_SUPPORTED)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
-endif()
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
 
 include(CheckFunctionExists)
 include(CheckSymbolExists)
diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 3c6223b015bb1..6458f2e174643 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -187,24 +187,18 @@ 
include_directories("${CMAKE_CURRENT_BINARY_DIR}/../clang/include")
 # form -W, and if supported, add the corresponding -Wno- option.
 
 # Disable GCC warnings
-check_cxx_compiler_flag("-Wdeprecated-declarations" 
CXX_SUPPORTS_DEPRECATED_DECLARATIONS)
-append_if(CXX_SUPPORTS_DEPRECATED_DECLARATIONS "-Wno-deprecated-declarations" 
CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wunknown-pragmas" CXX_SUPPORTS_UNKNOWN_PRAGMAS)
-append_if(CXX_SUPPORTS_UNKNOWN_PRAGMAS "-Wno-unknown-pragmas" CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wstrict-aliasing" CXX_SUPPORTS_STRICT_ALIASING)
-append_if(CXX_SUPPORTS_STRICT_ALIASING "-Wno-strict-aliasing" CMAKE_CXX_FLAGS)
+append("-Wno-deprecated-declarations" CMAKE_CXX_FLAGS)
+append("-Wno-unknown-pragmas" CMAKE_CXX_FLAGS)
+append("-Wno-strict-aliasing" CMAKE_CXX_FLAGS)
 
 check_cxx_compiler_flag("-Wstringop-truncation" 
CXX_SUPPORTS_STRINGOP_TRUNCATION)
 append_if(CXX_SUPPORTS_STRINGOP_TRUNCATION "-Wno-stringop-truncation" 
CMAKE_CXX_FLAGS)
 
 # Disable Clang warnings
-check_cxx_compiler_flag("-Wdeprecated-register" 
CXX_SUPPORTS_DEPRECATED_REGISTER)
-append_if(CXX_SUPPORTS_DEPRECATED_REGISTER "-Wno-deprecated-register" 
CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wvla-extension" CXX_SUPPORTS_VLA_EXTENSION)
-append_if(CXX_SUPPORTS_VLA_EXTENSION "-Wno-vla-extension" CMAKE_CXX_FLAGS)
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  append("-Wno-deprecated-register" CMAKE_CXX_FLAGS)
+  append("-Wno-vla-extension" CMAKE_CXX_FLAGS)
+endif()
 
 # Disable MSVC warnings
 if( MSVC )
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index bf1b110245bb2..0900e1107076e 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -415,15 +415,14 @@ if( LLVM_ENABLE_PIC )
   set(ENABLE_PIC 1)
 else()
   set(ENABLE_PIC 0)
-  check_cxx_compiler_flag("-fno-pie" SUPPORTS_NO_PIE_FLAG)
-  if(SUPPORTS_NO_PIE_FLAG)
-set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie")
-  endif()
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie")
 endif()
 
-check_cxx_compiler_flag("-Wvariadic-macros" SUPPORTS_VARIADIC_MACROS_FLAG)
-check_cxx_compiler_flag("-Wgnu-zero-variadic-macro-arguments"
-SUPPORTS_GNU_ZERO_VA

[Lldb-commits] [lldb] Change GetChildCompilerTypeAtIndex to return Expected (NFC) (PR #92979)

2024-05-22 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo approved this pull request.

Pretty nice! This will be useful for Mojo as well

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


[Lldb-commits] [lldb] [lldb-dap] Fix a race during shutdown (PR #91591)

2024-05-22 Thread via lldb-commits

kusmour wrote:

> > I can't remember: does terminate come before disconnecting? Or is it the 
> > other way around?
> 
> Disconnect docs say "The disconnect request asks the debug adapter to 
> disconnect from the debuggee (thus ending the debug session) and then to shut 
> down itself (the debug adapter).", so it has to be the last request. The 
> terminate just terminates the debuggee and, if the client&server support it, 
> the debuggee can be restarted after that.

This patch resulted in terminated event being sent twice for every session. One 
from `exited` event one from `disconnect` request. Before this patch the 
behavior was:
- Debuggee program exits
DAP msg: exited event --> terminated event --> disconnect request --> 
disconnect response
- User initiated stop debugging
DAP msg: disconnect request --> exited event --> terminated event --> 
disconnect response

Now
- Debuggee program exits
DAP msg: exited event --> terminated event --> disconnect request --> 
terminated event --> disconnect response
- User initiated stop debugging
DAP msg: disconnect request --> exited event --> terminated event --> 
disconnect response --> terminated event

(Also not sure why the terminated event comes after disconnect response in the 
second scenario)

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


[Lldb-commits] [lldb] [lldb/DWARF] Make sure bad abbreviation codes do not crash lldb (PR #93006)

2024-05-22 Thread Felipe de Azevedo Piovezan via lldb-commits

https://github.com/felipepiovezan approved this pull request.

LGTM! Thanks for catching this

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


[Lldb-commits] [lldb] A few updates around "transcript" (PR #92843)

2024-05-22 Thread via lldb-commits

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-05-22 Thread via lldb-commits

https://github.com/cmtice updated 
https://github.com/llvm/llvm-project/pull/87197

>From 68cb68d3f93aed6b3479fb305131b99ec599c9d8 Mon Sep 17 00:00:00 2001
From: Caroline Tice 
Date: Sun, 31 Mar 2024 10:59:38 -0700
Subject: [PATCH 1/4] [LLDB] Add more helper functions to ValueObject class.

Create additional helper functions for the ValueObject class, for:
  - returning the value as an APSInt or APFloat
  - additional type casting options
  - additional ways to create ValueObjects from various types of data
  - dereferencing a ValueObject

These helper functions are needed for implementing the Data Inspection
Language, described in
https://discourse.llvm.org/t/rfc-data-inspection-language/69893
---
 lldb/include/lldb/Core/ValueObject.h |  61 
 lldb/source/Core/ValueObject.cpp | 405 +++
 2 files changed, 466 insertions(+)

diff --git a/lldb/include/lldb/Core/ValueObject.h 
b/lldb/include/lldb/Core/ValueObject.h
index e7e35e2b2bffc..0c8dbf384a326 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -441,6 +441,19 @@ class ValueObject {
 
   virtual int64_t GetValueAsSigned(int64_t fail_value, bool *success = 
nullptr);
 
+  llvm::APSInt GetValueAsAPSInt();
+
+  llvm::APFloat GetValueAsFloat();
+
+  bool GetValueAsBool();
+
+  /// Update the value of the current object to be the integer in the 'value'
+  /// parameter.
+  void UpdateIntegerValue(const llvm::APInt &value);
+
+  /// Assign the integer value 'new_val_sp' to the current object.
+  void UpdateIntegerValue(lldb::ValueObjectSP new_val_sp);
+
   virtual bool SetValueFromCString(const char *value_str, Status &error);
 
   /// Return the module associated with this value object in case the value is
@@ -618,6 +631,24 @@ class ValueObject {
   virtual lldb::ValueObjectSP CastPointerType(const char *name,
   lldb::TypeSP &type_sp);
 
+  /// Return the target load address assocaited with this value object.
+  lldb::addr_t GetLoadAddress();
+
+  lldb::ValueObjectSP CastDerivedToBaseType(CompilerType type,
+const std::vector &idx);
+
+  lldb::ValueObjectSP CastBaseToDerivedType(CompilerType type, uint64_t 
offset);
+
+  lldb::ValueObjectSP CastScalarToBasicType(CompilerType type, Status &error);
+
+  lldb::ValueObjectSP CastEnumToBasicType(CompilerType type);
+
+  lldb::ValueObjectSP CastPointerToBasicType(CompilerType type);
+
+  lldb::ValueObjectSP CastIntegerOrEnumToEnumType(CompilerType type);
+
+  lldb::ValueObjectSP CastFloatToEnumType(CompilerType type, Status &error);
+
   /// If this object represents a C++ class with a vtable, return an object
   /// that represents the virtual function table. If the object isn't a class
   /// with a vtable, return a valid ValueObject with the error set correctly.
@@ -668,6 +699,32 @@ class ValueObject {
   CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data,
 const ExecutionContext &exe_ctx, CompilerType 
type);
 
+  static lldb::ValueObjectSP
+  CreateValueObjectFromBytes(lldb::TargetSP target_sp, const void *bytes,
+ CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromBytes(lldb::TargetSP target,
+const void *bytes,
+lldb::BasicType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromAPInt(lldb::TargetSP target,
+const llvm::APInt &v,
+CompilerType type);
+
+  static lldb::ValueObjectSP
+  CreateValueObjectFromAPFloat(lldb::TargetSP target, const llvm::APFloat &v,
+   CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromPointer(lldb::TargetSP 
target,
+  uintptr_t addr,
+  CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromBool(lldb::TargetSP target,
+   bool value);
+
+  static lldb::ValueObjectSP CreateValueObjectFromNullptr(lldb::TargetSP 
target,
+  CompilerType type);
+
   lldb::ValueObjectSP Persist();
 
   /// Returns true if this is a char* or a char[] if it is a char* and
@@ -719,6 +776,10 @@ class ValueObject {
 ClearUserVisibleData(eClearUserVisibleDataItemsSummary);
   }
 
+  void SetDerefValobj(ValueObject *deref) { m_deref_valobj = deref; }
+
+  ValueObject *GetDerefValobj() { return m_deref_valobj; }
+
   void SetValueFormat(lldb::TypeFormatImplSP format) {
 m_type_format_sp = std::move(format);
 ClearUserVisibleData(eClearUserVisibleDataItemsValue);
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/

[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-05-22 Thread via lldb-commits


@@ -668,6 +699,32 @@ class ValueObject {
   CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data,
 const ExecutionContext &exe_ctx, CompilerType 
type);
 
+  static lldb::ValueObjectSP
+  CreateValueObjectFromBytes(lldb::TargetSP target_sp, const void *bytes,
+ CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromBytes(lldb::TargetSP target,
+const void *bytes,
+lldb::BasicType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromAPInt(lldb::TargetSP target,

cmtice wrote:

Done


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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-05-22 Thread via lldb-commits


@@ -668,6 +699,32 @@ class ValueObject {
   CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data,
 const ExecutionContext &exe_ctx, CompilerType 
type);
 
+  static lldb::ValueObjectSP
+  CreateValueObjectFromBytes(lldb::TargetSP target_sp, const void *bytes,
+ CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromBytes(lldb::TargetSP target,
+const void *bytes,
+lldb::BasicType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromAPInt(lldb::TargetSP target,
+const llvm::APInt &v,
+CompilerType type);
+
+  static lldb::ValueObjectSP
+  CreateValueObjectFromAPFloat(lldb::TargetSP target, const llvm::APFloat &v,

cmtice wrote:

Done

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-05-22 Thread via lldb-commits


@@ -668,6 +699,32 @@ class ValueObject {
   CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data,
 const ExecutionContext &exe_ctx, CompilerType 
type);
 
+  static lldb::ValueObjectSP
+  CreateValueObjectFromBytes(lldb::TargetSP target_sp, const void *bytes,
+ CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromBytes(lldb::TargetSP target,
+const void *bytes,
+lldb::BasicType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromAPInt(lldb::TargetSP target,
+const llvm::APInt &v,
+CompilerType type);
+
+  static lldb::ValueObjectSP
+  CreateValueObjectFromAPFloat(lldb::TargetSP target, const llvm::APFloat &v,
+   CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromPointer(lldb::TargetSP 
target,
+  uintptr_t addr,
+  CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromBool(lldb::TargetSP target,

cmtice wrote:

Done

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-05-22 Thread via lldb-commits


@@ -668,6 +699,32 @@ class ValueObject {
   CreateValueObjectFromData(llvm::StringRef name, const DataExtractor &data,
 const ExecutionContext &exe_ctx, CompilerType 
type);
 
+  static lldb::ValueObjectSP
+  CreateValueObjectFromBytes(lldb::TargetSP target_sp, const void *bytes,
+ CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromBytes(lldb::TargetSP target,
+const void *bytes,
+lldb::BasicType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromAPInt(lldb::TargetSP target,
+const llvm::APInt &v,
+CompilerType type);
+
+  static lldb::ValueObjectSP
+  CreateValueObjectFromAPFloat(lldb::TargetSP target, const llvm::APFloat &v,
+   CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromPointer(lldb::TargetSP 
target,
+  uintptr_t addr,
+  CompilerType type);
+
+  static lldb::ValueObjectSP CreateValueObjectFromBool(lldb::TargetSP target,
+   bool value);
+
+  static lldb::ValueObjectSP CreateValueObjectFromNullptr(lldb::TargetSP 
target,

cmtice wrote:

Done

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-05-22 Thread via lldb-commits


@@ -1089,6 +1089,116 @@ int64_t ValueObject::GetValueAsSigned(int64_t 
fail_value, bool *success) {
   return fail_value;
 }
 
+llvm::APSInt ValueObject::GetValueAsAPSInt() {
+  lldb::TargetSP target = GetTargetSP();
+  uint64_t byte_size = 0;
+  if (auto temp = GetCompilerType().GetByteSize(target.get()))
+byte_size = temp.value();
+
+  unsigned bit_width = static_cast(byte_size * CHAR_BIT);
+  bool success = true;
+  uint64_t fail_value = 0;
+  uint64_t ret_val = GetValueAsUnsigned(fail_value, &success);
+  uint64_t new_value = fail_value;
+  if (success)
+new_value = ret_val;
+  bool is_signed = GetCompilerType().IsSigned();
+
+  return llvm::APSInt(llvm::APInt(bit_width, new_value, is_signed), 
!is_signed);
+}
+
+llvm::APFloat ValueObject::GetValueAsFloat() {
+  lldb::BasicType basic_type =
+  GetCompilerType().GetCanonicalType().GetBasicTypeEnumeration();
+  lldb::DataExtractorSP data_sp(new DataExtractor());
+  Status error;
+
+  switch (basic_type) {
+  case lldb::eBasicTypeFloat: {
+float v = 0;
+GetData(*data_sp, error);
+assert(error.Success() && "Unable to read float data from value");
+
+lldb::offset_t offset = 0;
+uint32_t old_offset = offset;
+void *ok = nullptr;
+ok = data_sp->GetU8(&offset, (void *)&v, sizeof(float));
+assert(offset != old_offset && ok != nullptr && "unable to read data");
+
+return llvm::APFloat(v);
+  }
+  case lldb::eBasicTypeDouble:
+// No way to get more precision at the moment.
+  case lldb::eBasicTypeLongDouble: {
+double v = 0;
+GetData(*data_sp, error);
+assert(error.Success() && "Unable to read long double data from value");
+
+lldb::offset_t offset = 0;
+uint32_t old_offset = offset;
+void *ok = nullptr;
+ok = data_sp->GetU8(&offset, (void *)&v, sizeof(double));
+assert(offset != old_offset && ok != nullptr && "unable to read data");
+
+return llvm::APFloat(v);
+  }
+  default:
+return llvm::APFloat(NAN);
+  }
+}
+
+bool ValueObject::GetValueAsBool() {
+  CompilerType val_type = GetCompilerType();
+  if (val_type.IsInteger() || val_type.IsUnscopedEnumerationType() ||
+  val_type.IsPointerType()) {
+return GetValueAsAPSInt().getBoolValue();
+  }
+  if (val_type.IsFloat()) {
+return GetValueAsFloat().isNonZero();
+  }
+  if (val_type.IsArrayType()) {
+lldb::ValueObjectSP new_val =
+ValueObject::ValueObject::CreateValueObjectFromAddress(
+GetName().GetStringRef(), GetAddressOf(), GetExecutionContextRef(),
+val_type);
+return new_val->GetValueAsUnsigned(0) != 0;
+  }
+  return false;
+}
+
+void ValueObject::UpdateIntegerValue(const llvm::APInt &value) {
+  lldb::TargetSP target = GetTargetSP();
+  uint64_t byte_size = 0;
+  if (auto temp = GetCompilerType().GetByteSize(target.get()))
+byte_size = temp.value();
+
+  assert(value.getBitWidth() == byte_size * CHAR_BIT &&
+ "illegal argument: new value should be of the same size");
+
+  lldb::DataExtractorSP data_sp;
+  Status error;
+  data_sp->SetData(value.getRawData(), byte_size,
+   target->GetArchitecture().GetByteOrder());
+  data_sp->SetAddressByteSize(
+  static_cast(target->GetArchitecture().GetAddressByteSize()));
+  SetData(*data_sp, error);
+}
+
+void ValueObject::UpdateIntegerValue(lldb::ValueObjectSP new_val_sp) {
+  CompilerType new_val_type = new_val_sp->GetCompilerType();
+  assert((new_val_type.IsInteger() || new_val_type.IsFloat() ||
+  new_val_type.IsPointerType()) &&
+ "illegal argument: new value should be of the same size");
+
+  if (new_val_type.IsInteger()) {

cmtice wrote:

Done (I thiink!)

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-05-22 Thread via lldb-commits

cmtice wrote:

I'm sorry this has taken me so long, but I believe I have addressed/fixed 
everyone's comments now; if I missed any please let me know.  Please review 
this PR again. 

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


[Lldb-commits] [lldb] [lldb-dap] Fix a race during shutdown (PR #91591)

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

labath wrote:

Ah yes, of course, I've kept the mutex thinking that its sufficient to make it 
run only once, but of course that's only true if the critical section actually 
contains a "run once" check. I'll create a patch for that tomorrow. Feel free 
to revert in the mean time if this is blocking something.

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


[Lldb-commits] [lldb] [LLDB] Add more helper functions to ValueObject class. (PR #87197)

2024-05-22 Thread via lldb-commits


@@ -2809,6 +2919,243 @@ ValueObjectSP ValueObject::CastPointerType(const char 
*name, TypeSP &type_sp) {
   return valobj_sp;
 }
 
+lldb::addr_t ValueObject::GetLoadAddress() {
+  lldb::addr_t addr_value = LLDB_INVALID_ADDRESS;
+  lldb::TargetSP target_sp = GetTargetSP();
+  if (target_sp) {
+const bool scalar_is_load_address = true;
+AddressType addr_type;
+addr_value = GetAddressOf(scalar_is_load_address, &addr_type);
+if (addr_type == eAddressTypeFile) {
+  lldb::ModuleSP module_sp(GetModule());
+  if (!module_sp)
+addr_value = LLDB_INVALID_ADDRESS;
+  else {
+Address tmp_addr;
+module_sp->ResolveFileAddress(addr_value, tmp_addr);
+addr_value = tmp_addr.GetLoadAddress(target_sp.get());
+  }
+} else if (addr_type == eAddressTypeHost || addr_type == eAddressTypeHost)
+  addr_value = LLDB_INVALID_ADDRESS;
+  }
+  return addr_value;
+}
+
+lldb::ValueObjectSP
+ValueObject::CastDerivedToBaseType(CompilerType type,
+   const std::vector &idx) {
+
+  lldb::TargetSP target = GetTargetSP();
+  assert((type.IsPointerType() || type.IsReferenceType()) &&
+ "invalid ast: target type should be a pointer or a reference");
+  assert(!idx.empty() && "invalid ast: children sequence should be non-empty");
+
+  // The `value` can be a pointer, but GetChildAtIndex works for pointers too.
+  lldb::ValueObjectSP inner_value;
+
+  for (const uint32_t i : idx) {
+// Force static value, otherwise we can end up with the "real" type.
+inner_value = GetChildAtIndex(i, /*can_create_synthetic*/ false);

cmtice wrote:

Ah, OOPS! I just re-discovered this comment, and it's actually a bug in my code 
(I mis-copied something). It should be "inner_value = 
inner_value.GetChildAtIndex(...). I will fix that and send the fix later today.

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-22 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/92492

>From 304528acdd3590bf4d8d1a03e31fd0970ed2eaa2 Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Tue, 14 May 2024 16:18:20 -0700
Subject: [PATCH] Read and store gnu build id from loaded core file

---
 .../Plugins/ObjectFile/ELF/ELFHeader.cpp  | 13 +++
 .../source/Plugins/ObjectFile/ELF/ELFHeader.h | 27 ++
 .../Process/elf-core/ProcessElfCore.cpp   | 87 +++
 .../Plugins/Process/elf-core/ProcessElfCore.h | 15 
 4 files changed, 142 insertions(+)

diff --git a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
index a6e385f70709b..fcb677ed28a92 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
@@ -252,6 +252,19 @@ bool ELFSectionHeader::Parse(const 
lldb_private::DataExtractor &data,
   return true;
 }
 
+// SectionNote
+
+SectionNote::SectionNote() { memset(this, 0, sizeof(SectionNote)); }
+
+bool SectionNote::Parse(const lldb_private::DataExtractor &data,
+lldb::offset_t *offset) {
+  // Read sn_namesz and sn_descsz, sn_type.
+  if (data.GetU32(offset, &sn_namesz, 3) == nullptr)
+return false;
+
+  return true;
+}
+
 // ELFSymbol
 
 ELFSymbol::ELFSymbol() { memset(this, 0, sizeof(ELFSymbol)); }
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h 
b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
index 963cc850736ff..baf35d4a78c18 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
+++ b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
@@ -271,6 +271,33 @@ struct ELFSymbol {
 const lldb_private::SectionList *section_list);
 };
 
+/// \class SectionNote
+/// Represents an entry of PT_NOTE in program header
+struct SectionNote {
+  elf_word sn_namesz;
+  elf_word sn_descsz;
+  elf_word sn_type;
+
+  SectionNote();
+
+  /// Parse an SectionNote entry from the given DataExtractor starting at
+  /// position \p offset.  The address size of the DataExtractor determines if
+  /// a 32 or 64 bit object is to be parsed.
+  ///
+  /// \param[in] data
+  ///The DataExtractor to read from.  The address size of the extractor
+  ///determines if a 32 or 64 bit object should be read.
+  ///
+  /// \param[in,out] offset
+  ///Pointer to an offset in the data.  On return the offset will be
+  ///advanced by the number of bytes read.
+  ///
+  /// \return
+  ///True if the SectionNote was successfully read and false
+  ///otherwise.
+  bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
+};
+
 /// \class ELFDynamic
 /// Represents an entry in an ELF dynamic table.
 struct ELFDynamic {
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 36812c27a5b6d..4e5e70ceae438 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -6,11 +6,14 @@
 //
 
//===--===//
 
+#include 
 #include 
 
 #include 
 #include 
+#include 
 
+#include "Plugins/ObjectFile/ELF/ELFHeader.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"
@@ -33,6 +36,7 @@
 #include "Plugins/Process/elf-core/RegisterUtilities.h"
 #include "ProcessElfCore.h"
 #include "ThreadElfCore.h"
+#include "lldb/lldb-types.h"
 
 using namespace lldb_private;
 namespace ELF = llvm::ELF;
@@ -250,6 +254,9 @@ Status ProcessElfCore::DoLoadCore() {
 }
   }
 
+  // Try to find gnu build id before we load the executable.
+  UpdateBuildIdForNTFileEntries();
+
   // Core files are useless without the main executable. See if we can locate
   // the main executable using data we found in the core file notes.
   lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
@@ -258,6 +265,7 @@ Status ProcessElfCore::DoLoadCore() {
 if (!m_nt_file_entries.empty()) {
   ModuleSpec exe_module_spec;
   exe_module_spec.GetArchitecture() = arch;
+  exe_module_spec.GetUUID() = m_nt_file_entries[0].uuid;
   exe_module_spec.GetFileSpec().SetFile(m_nt_file_entries[0].path,
 FileSpec::Style::native);
   if (exe_module_spec.GetFileSpec()) {
@@ -271,6 +279,17 @@ Status ProcessElfCore::DoLoadCore() {
   return error;
 }
 
+void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
+  if (!m_nt_file_entries.empty()) {
+for (NT_FILE_Entry &entry : m_nt_file_entries) {
+  std::optional uuid =
+  FindNoteInCoreMemory(entry.start, llvm::ELF::NT_GNU_BUILD_ID);
+  if (uuid)
+entry.uuid = uuid.value();
+}
+  }
+}
+
 lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
   if (m_dyld_up.get() == nullptr)
 m_dyld_up.reset(DynamicLoader::FindPlugin(
@@ -983,6 +1002,74 @@ llvm::Error 
ProcessElfC

[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-22 Thread via lldb-commits


@@ -271,6 +282,17 @@ Status ProcessElfCore::DoLoadCore() {
   return error;
 }
 
+void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
+  if (!m_nt_file_entries.empty()) {

GeorgeHuyubo wrote:

@labath 
There are two reasons,
1. We need to do this after we load PT_LOAD segment, so that we have address 
map which is essential to ReadMemory. PT_LOAD is usually after PT_NOTE afaik.
2. We need to do this after the core architecture is set, so 
GetAddressByteSize() will return non zero value.

@kevinfrei 
During the pass, it's parsing the elf header of the core file, during which we 
don't have the gnu build id in there yet. We need to let the pass finish so 
that we have the core file loaded into memory, and then we will need to read 
from certain memory region which represent a loaded module and parse the elf 
header there to get the gnu build id. 

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


[Lldb-commits] [lldb] Change GetChildCompilerTypeAtIndex to return Expected (NFC) (PR #92979)

2024-05-22 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl updated 
https://github.com/llvm/llvm-project/pull/92979

>From a8503fb49ef7964dbde318df103546bde72f7b42 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Tue, 21 May 2024 17:41:31 -0700
Subject: [PATCH] Change GetChildCompilerTypeAtIndex to return Expected (NFC)

---
 lldb/include/lldb/Symbol/CompilerType.h   |  2 +-
 lldb/include/lldb/Symbol/TypeSystem.h |  2 +-
 lldb/source/Core/ValueObject.cpp  | 31 ++-
 .../Core/ValueObjectConstResultImpl.cpp   | 12 +--
 .../Plugins/ABI/PowerPC/ABISysV_ppc64.cpp |  3 +-
 .../Language/CPlusPlus/BlockPointer.cpp   | 18 ++-
 .../Plugins/Language/CPlusPlus/LibCxxMap.cpp  | 14 -
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 18 ++-
 .../TypeSystem/Clang/TypeSystemClang.h|  2 +-
 lldb/source/Symbol/CompilerType.cpp   |  2 +-
 10 files changed, 67 insertions(+), 37 deletions(-)

diff --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index 28c723abf2794..70dacdcb7986f 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -436,7 +436,7 @@ class CompilerType {
uint32_t *bitfield_bit_size_ptr = nullptr,
bool *is_bitfield_ptr = nullptr) const;
 
-  CompilerType GetChildCompilerTypeAtIndex(
+  llvm::Expected GetChildCompilerTypeAtIndex(
   ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers,
   bool omit_empty_base_classes, bool ignore_array_bounds,
   std::string &child_name, uint32_t &child_byte_size,
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index 7bcb8d69387a0..b4025c173a186 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -359,7 +359,7 @@ class TypeSystem : public PluginInterface,
 return CompilerDecl();
   }
 
-  virtual CompilerType GetChildCompilerTypeAtIndex(
+  virtual llvm::Expected GetChildCompilerTypeAtIndex(
   lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
   bool transparent_pointers, bool omit_empty_base_classes,
   bool ignore_array_bounds, std::string &child_name,
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index f39bd07a25536..1443d9dfc3280 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -505,15 +505,23 @@ ValueObject *ValueObject::CreateChildAtIndex(size_t idx,
   uint64_t language_flags = 0;
 
   const bool transparent_pointers = !synthetic_array_member;
-  CompilerType child_compiler_type;
 
   ExecutionContext exe_ctx(GetExecutionContextRef());
 
-  child_compiler_type = GetCompilerType().GetChildCompilerTypeAtIndex(
-  &exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
-  ignore_array_bounds, child_name_str, child_byte_size, child_byte_offset,
-  child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
-  child_is_deref_of_parent, this, language_flags);
+  auto child_compiler_type_or_err =
+  GetCompilerType().GetChildCompilerTypeAtIndex(
+  &exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
+  ignore_array_bounds, child_name_str, child_byte_size,
+  child_byte_offset, child_bitfield_bit_size, 
child_bitfield_bit_offset,
+  child_is_base_class, child_is_deref_of_parent, this, language_flags);
+  CompilerType child_compiler_type;
+  if (!child_compiler_type_or_err)
+LLDB_LOG_ERROR(GetLog(LLDBLog::Types),
+   child_compiler_type_or_err.takeError(),
+   "could not find child: {0}");
+  else
+child_compiler_type = *child_compiler_type_or_err;
+
   if (child_compiler_type) {
 if (synthetic_index)
   child_byte_offset += child_byte_size * synthetic_index;
@@ -2624,16 +2632,23 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
 bool child_is_deref_of_parent = false;
 const bool transparent_pointers = false;
 CompilerType compiler_type = GetCompilerType();
-CompilerType child_compiler_type;
 uint64_t language_flags = 0;
 
 ExecutionContext exe_ctx(GetExecutionContextRef());
 
-child_compiler_type = compiler_type.GetChildCompilerTypeAtIndex(
+CompilerType child_compiler_type;
+auto child_compiler_type_or_err = 
compiler_type.GetChildCompilerTypeAtIndex(
 &exe_ctx, 0, transparent_pointers, omit_empty_base_classes,
 ignore_array_bounds, child_name_str, child_byte_size, 
child_byte_offset,
 child_bitfield_bit_size, child_bitfield_bit_offset, 
child_is_base_class,
 child_is_deref_of_parent, this, language_flags);
+if (!child_compiler_type_or_err)
+  LLDB_LOG_ERROR(GetLog(LLDBLog::Types),
+ child_compiler_type_or_err.takeError(),
+ "could not find child: {0}");
+else
+  child_

[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-22 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/92492

>From fc7ae3cd19a999375504733be6c942978d80d5d7 Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Tue, 14 May 2024 16:18:20 -0700
Subject: [PATCH] Read and store gnu build id from loaded core file

---
 .../Plugins/ObjectFile/ELF/ELFHeader.cpp  | 13 +++
 .../source/Plugins/ObjectFile/ELF/ELFHeader.h | 25 ++
 .../Process/elf-core/ProcessElfCore.cpp   | 87 +++
 .../Plugins/Process/elf-core/ProcessElfCore.h | 15 
 4 files changed, 140 insertions(+)

diff --git a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
index a6e385f70709b..fcb677ed28a92 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp
@@ -252,6 +252,19 @@ bool ELFSectionHeader::Parse(const 
lldb_private::DataExtractor &data,
   return true;
 }
 
+// SectionNote
+
+SectionNote::SectionNote() { memset(this, 0, sizeof(SectionNote)); }
+
+bool SectionNote::Parse(const lldb_private::DataExtractor &data,
+lldb::offset_t *offset) {
+  // Read sn_namesz and sn_descsz, sn_type.
+  if (data.GetU32(offset, &sn_namesz, 3) == nullptr)
+return false;
+
+  return true;
+}
+
 // ELFSymbol
 
 ELFSymbol::ELFSymbol() { memset(this, 0, sizeof(ELFSymbol)); }
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h 
b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
index 963cc850736ff..da6dfc7343bcf 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
+++ b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.h
@@ -271,6 +271,31 @@ struct ELFSymbol {
 const lldb_private::SectionList *section_list);
 };
 
+/// \class SectionNote
+/// Represents an entry of PT_NOTE in program header
+struct SectionNote {
+  elf_word sn_namesz;
+  elf_word sn_descsz;
+  elf_word sn_type;
+
+  SectionNote();
+
+  /// Parse an SectionNote entry from the given DataExtractor starting at
+  /// position \p offset.
+  ///
+  /// \param[in] data
+  ///The DataExtractor to read from.
+  ///
+  /// \param[in,out] offset
+  ///Pointer to an offset in the data.  On return the offset will be
+  ///advanced by the number of bytes read.
+  ///
+  /// \return
+  ///True if the SectionNote was successfully read and false
+  ///otherwise.
+  bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
+};
+
 /// \class ELFDynamic
 /// Represents an entry in an ELF dynamic table.
 struct ELFDynamic {
diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 36812c27a5b6d..4e5e70ceae438 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -6,11 +6,14 @@
 //
 
//===--===//
 
+#include 
 #include 
 
 #include 
 #include 
+#include 
 
+#include "Plugins/ObjectFile/ELF/ELFHeader.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"
@@ -33,6 +36,7 @@
 #include "Plugins/Process/elf-core/RegisterUtilities.h"
 #include "ProcessElfCore.h"
 #include "ThreadElfCore.h"
+#include "lldb/lldb-types.h"
 
 using namespace lldb_private;
 namespace ELF = llvm::ELF;
@@ -250,6 +254,9 @@ Status ProcessElfCore::DoLoadCore() {
 }
   }
 
+  // Try to find gnu build id before we load the executable.
+  UpdateBuildIdForNTFileEntries();
+
   // Core files are useless without the main executable. See if we can locate
   // the main executable using data we found in the core file notes.
   lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
@@ -258,6 +265,7 @@ Status ProcessElfCore::DoLoadCore() {
 if (!m_nt_file_entries.empty()) {
   ModuleSpec exe_module_spec;
   exe_module_spec.GetArchitecture() = arch;
+  exe_module_spec.GetUUID() = m_nt_file_entries[0].uuid;
   exe_module_spec.GetFileSpec().SetFile(m_nt_file_entries[0].path,
 FileSpec::Style::native);
   if (exe_module_spec.GetFileSpec()) {
@@ -271,6 +279,17 @@ Status ProcessElfCore::DoLoadCore() {
   return error;
 }
 
+void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
+  if (!m_nt_file_entries.empty()) {
+for (NT_FILE_Entry &entry : m_nt_file_entries) {
+  std::optional uuid =
+  FindNoteInCoreMemory(entry.start, llvm::ELF::NT_GNU_BUILD_ID);
+  if (uuid)
+entry.uuid = uuid.value();
+}
+  }
+}
+
 lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
   if (m_dyld_up.get() == nullptr)
 m_dyld_up.reset(DynamicLoader::FindPlugin(
@@ -983,6 +1002,74 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+bool ProcessElfCore::IsElf(lldb::addr_t address) {
+  uint8_t buf[4];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, 4, error);

[Lldb-commits] [lldb] ac1dc05 - Change GetChildCompilerTypeAtIndex to return Expected (NFC) (#92979)

2024-05-22 Thread via lldb-commits

Author: Adrian Prantl
Date: 2024-05-22T08:52:33-07:00
New Revision: ac1dc05b331d35f341631f798673fe8aafdda53d

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

LOG: Change GetChildCompilerTypeAtIndex to return Expected (NFC) (#92979)

This change is a general improvement of the internal API. My motivation
is to use this in the Swift typesystem plugin.

Added: 


Modified: 
lldb/include/lldb/Symbol/CompilerType.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/Core/ValueObject.cpp
lldb/source/Core/ValueObjectConstResultImpl.cpp
lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
lldb/source/Plugins/Language/CPlusPlus/LibCxxMap.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/source/Symbol/CompilerType.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/CompilerType.h 
b/lldb/include/lldb/Symbol/CompilerType.h
index 28c723abf2794..70dacdcb7986f 100644
--- a/lldb/include/lldb/Symbol/CompilerType.h
+++ b/lldb/include/lldb/Symbol/CompilerType.h
@@ -436,7 +436,7 @@ class CompilerType {
uint32_t *bitfield_bit_size_ptr = nullptr,
bool *is_bitfield_ptr = nullptr) const;
 
-  CompilerType GetChildCompilerTypeAtIndex(
+  llvm::Expected GetChildCompilerTypeAtIndex(
   ExecutionContext *exe_ctx, size_t idx, bool transparent_pointers,
   bool omit_empty_base_classes, bool ignore_array_bounds,
   std::string &child_name, uint32_t &child_byte_size,

diff  --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index 7bcb8d69387a0..b4025c173a186 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -359,7 +359,7 @@ class TypeSystem : public PluginInterface,
 return CompilerDecl();
   }
 
-  virtual CompilerType GetChildCompilerTypeAtIndex(
+  virtual llvm::Expected GetChildCompilerTypeAtIndex(
   lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, size_t idx,
   bool transparent_pointers, bool omit_empty_base_classes,
   bool ignore_array_bounds, std::string &child_name,

diff  --git a/lldb/source/Core/ValueObject.cpp 
b/lldb/source/Core/ValueObject.cpp
index f39bd07a25536..1443d9dfc3280 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -505,15 +505,23 @@ ValueObject *ValueObject::CreateChildAtIndex(size_t idx,
   uint64_t language_flags = 0;
 
   const bool transparent_pointers = !synthetic_array_member;
-  CompilerType child_compiler_type;
 
   ExecutionContext exe_ctx(GetExecutionContextRef());
 
-  child_compiler_type = GetCompilerType().GetChildCompilerTypeAtIndex(
-  &exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
-  ignore_array_bounds, child_name_str, child_byte_size, child_byte_offset,
-  child_bitfield_bit_size, child_bitfield_bit_offset, child_is_base_class,
-  child_is_deref_of_parent, this, language_flags);
+  auto child_compiler_type_or_err =
+  GetCompilerType().GetChildCompilerTypeAtIndex(
+  &exe_ctx, idx, transparent_pointers, omit_empty_base_classes,
+  ignore_array_bounds, child_name_str, child_byte_size,
+  child_byte_offset, child_bitfield_bit_size, 
child_bitfield_bit_offset,
+  child_is_base_class, child_is_deref_of_parent, this, language_flags);
+  CompilerType child_compiler_type;
+  if (!child_compiler_type_or_err)
+LLDB_LOG_ERROR(GetLog(LLDBLog::Types),
+   child_compiler_type_or_err.takeError(),
+   "could not find child: {0}");
+  else
+child_compiler_type = *child_compiler_type_or_err;
+
   if (child_compiler_type) {
 if (synthetic_index)
   child_byte_offset += child_byte_size * synthetic_index;
@@ -2624,16 +2632,23 @@ ValueObjectSP ValueObject::Dereference(Status &error) {
 bool child_is_deref_of_parent = false;
 const bool transparent_pointers = false;
 CompilerType compiler_type = GetCompilerType();
-CompilerType child_compiler_type;
 uint64_t language_flags = 0;
 
 ExecutionContext exe_ctx(GetExecutionContextRef());
 
-child_compiler_type = compiler_type.GetChildCompilerTypeAtIndex(
+CompilerType child_compiler_type;
+auto child_compiler_type_or_err = 
compiler_type.GetChildCompilerTypeAtIndex(
 &exe_ctx, 0, transparent_pointers, omit_empty_base_classes,
 ignore_array_bounds, child_name_str, child_byte_size, 
child_byte_offset,
 child_bitfield_bit_size, child_bitfield_bit_offset, 
child_is_base_class,
 child_is_deref_of_parent, this, language_flags);
+if (!child_compiler_type_or_err)
+  L

[Lldb-commits] [lldb] Change GetChildCompilerTypeAtIndex to return Expected (NFC) (PR #92979)

2024-05-22 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb][FreeBSD][AArch64] Enable register field detection (PR #85058)

2024-05-22 Thread Andrew Turner via lldb-commits

zxombie wrote:

It looks like `svcr` is for SME & `mte_ctrl` is for MTE. Neither of these are 
currently supported in FreeBSD. When they are supported the appropriate `HWCAP` 
flags (and `ID_AA64*` registers) will be set to tell userspace it can use them.

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-22 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/92492

>From 4e4ca8edc4116cba0925cca8229bd5b1cb002b21 Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Tue, 14 May 2024 16:18:20 -0700
Subject: [PATCH] Read and store gnu build id from loaded core file

---
 .../Process/elf-core/ProcessElfCore.cpp   | 87 ++-
 .../Plugins/Process/elf-core/ProcessElfCore.h | 14 ++-
 2 files changed, 97 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 36812c27a5b6d..3a126220fabf0 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -6,11 +6,14 @@
 //
 
//===--===//
 
+#include 
 #include 
 
 #include 
 #include 
+#include 
 
+#include "Plugins/ObjectFile/ELF/ELFHeader.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"
@@ -33,6 +36,7 @@
 #include "Plugins/Process/elf-core/RegisterUtilities.h"
 #include "ProcessElfCore.h"
 #include "ThreadElfCore.h"
+#include "lldb/lldb-types.h"
 
 using namespace lldb_private;
 namespace ELF = llvm::ELF;
@@ -250,6 +254,9 @@ Status ProcessElfCore::DoLoadCore() {
 }
   }
 
+  // Try to find gnu build id before we load the executable.
+  UpdateBuildIdForNTFileEntries();
+
   // Core files are useless without the main executable. See if we can locate
   // the main executable using data we found in the core file notes.
   lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
@@ -258,6 +265,7 @@ Status ProcessElfCore::DoLoadCore() {
 if (!m_nt_file_entries.empty()) {
   ModuleSpec exe_module_spec;
   exe_module_spec.GetArchitecture() = arch;
+  exe_module_spec.GetUUID() = m_nt_file_entries[0].uuid;
   exe_module_spec.GetFileSpec().SetFile(m_nt_file_entries[0].path,
 FileSpec::Style::native);
   if (exe_module_spec.GetFileSpec()) {
@@ -271,6 +279,17 @@ Status ProcessElfCore::DoLoadCore() {
   return error;
 }
 
+void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
+  if (!m_nt_file_entries.empty()) {
+for (NT_FILE_Entry &entry : m_nt_file_entries) {
+  std::optional uuid =
+  FindNoteInCoreMemory(entry.start, llvm::ELF::NT_GNU_BUILD_ID);
+  if (uuid)
+entry.uuid = uuid.value();
+}
+  }
+}
+
 lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
   if (m_dyld_up.get() == nullptr)
 m_dyld_up.reset(DynamicLoader::FindPlugin(
@@ -570,11 +589,13 @@ static void ParseOpenBSDProcInfo(ThreadData &thread_data,
 }
 
 llvm::Expected>
-ProcessElfCore::parseSegment(const DataExtractor &segment) {
+ProcessElfCore::parseSegment(const DataExtractor &segment,
+ unsigned long segment_size) {
   lldb::offset_t offset = 0;
   std::vector result;
-
-  while (offset < segment.GetByteSize()) {
+  unsigned long note_size =
+  segment_size == 0 ? segment.GetByteSize() : segment_size;
+  while (offset < note_size) {
 ELFNote note = ELFNote();
 if (!note.Parse(segment, &offset))
   return llvm::make_error(
@@ -983,6 +1004,66 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+bool ProcessElfCore::IsElf(lldb::addr_t address) {
+  uint8_t buf[4];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, 4, error);
+  if (byte_read != 4)
+return false;
+  return elf::ELFHeader::MagicBytesMatch(buf);
+}
+
+std::optional ProcessElfCore::FindNoteInCoreMemory(lldb::addr_t address,
+ uint32_t type) {
+  if (!IsElf(address))
+return std::nullopt;
+  const uint32_t addr_size = GetAddressByteSize();
+  const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr)
+: 
sizeof(llvm::ELF::Elf64_Ehdr);
+
+  unsigned char buf[4096];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, elf_header_size, error);
+  if (byte_read != elf_header_size)
+return std::nullopt;
+  DataExtractor data(buf, 4096, GetByteOrder(), addr_size);
+  lldb::offset_t offset = 0;
+
+  elf::ELFHeader elf_header;
+  elf_header.Parse(data, &offset);
+
+  const lldb::addr_t ph_addr = address + elf_header.e_phoff;
+
+  for (unsigned int i = 0; i < elf_header.e_phnum; ++i) {
+byte_read = ReadMemory(ph_addr + i * elf_header.e_phentsize, buf,
+   elf_header.e_phentsize, error);
+if (byte_read != elf_header.e_phentsize)
+  break;
+offset = 0;
+elf::ELFProgramHeader program_header;
+program_header.Parse(data, &offset);
+if (program_header.p_type != llvm::ELF::PT_NOTE)
+  continue;
+
+byte_read =
+ReadMemory(program_header.p_vaddr, buf, program_header.p_memsz, error);
+if (byte_read != program_

[Lldb-commits] [lldb] 8df5a37 - [lldb] Fix a warning

2024-05-22 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2024-05-22T10:09:10-07:00
New Revision: 8df5a37b848c6ac5a68b56eeddb4a7746b84d288

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

LOG: [lldb] Fix a warning

This patch fixes:

  lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp:839:7: error:
  ignoring return value of function declared with 'nodiscard'
  attribute [-Werror,-Wunused-result]

Added: 


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

Removed: 




diff  --git a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp 
b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
index 3d9b4566ca1c9..7a6b7429fddbf 100644
--- a/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
+++ b/lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp
@@ -836,7 +836,7 @@ class ReturnValueExtractor {
 for (uint32_t i = 0; i < n; i++) {
   std::string name;
   uint32_t size;
-  GetChildType(i, name, size);
+  (void)GetChildType(i, name, size);
   // NOTE: the offset returned by GetChildCompilerTypeAtIndex()
   //   can't be used because it never considers alignment bytes
   //   between struct fields.



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


[Lldb-commits] [lldb] [lldb] Added Debuginfod tests and fixed a couple issues (PR #92572)

2024-05-22 Thread Greg Clayton via lldb-commits

https://github.com/clayborg approved this pull request.


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


[Lldb-commits] [lldb] e558d21 - [lldb] Added Debuginfod tests and fixed a couple issues (#92572)

2024-05-22 Thread via lldb-commits

Author: Kevin Frei
Date: 2024-05-22T10:31:04-07:00
New Revision: e558d21e87882d40e29d858b1269ee8f1ddf2a38

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

LOG: [lldb] Added Debuginfod tests and fixed a couple issues (#92572)

Here we go with attempt number five. Again, no changes to the LLDB code
diff, which has been reviewed several times.

For the tests, I added a `@skipIfCurlSupportMissing` annotation so that
the Debuginfod mocked server stuff won't run, and I also disabled
non-Linux/FreeBSD hosts altogether, as they fail for platform reasons on
macOS and Windows. In addition, I updated the process for extracting the
GNU BuildID to no create a target, per some feedback on the previous
diff.

For reference, previous PR's (landed, backed out after the fact for
various reasons) #90622, #87676, #86812, #85693

-

Co-authored-by: Kevin Frei 

Added: 
lldb/test/API/debuginfod/Normal/Makefile
lldb/test/API/debuginfod/Normal/TestDebuginfod.py
lldb/test/API/debuginfod/Normal/main.c
lldb/test/API/debuginfod/SplitDWARF/Makefile
lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py
lldb/test/API/debuginfod/SplitDWARF/main.c

Modified: 
lldb/include/lldb/Host/Config.h.cmake
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/make/Makefile.rules
lldb/source/API/SBDebugger.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolLocator/CMakeLists.txt
lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/Config.h.cmake 
b/lldb/include/lldb/Host/Config.h.cmake
index 3defa454f6d42..9e538534086a2 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -33,6 +33,8 @@
 
 #cmakedefine01 LLDB_ENABLE_LZMA
 
+#cmakedefine01 LLVM_ENABLE_CURL
+
 #cmakedefine01 LLDB_ENABLE_CURSES
 
 #cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H

diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 79cc0a2aeacbe..b4ac3bdabac86 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1055,6 +1055,10 @@ def _get_bool_config_skip_if_decorator(key):
 return unittest.skipIf(not have, "requires " + key)
 
 
+def skipIfCurlSupportMissing(func):
+return _get_bool_config_skip_if_decorator("curl")(func)
+
+
 def skipIfCursesSupportMissing(func):
 return _get_bool_config_skip_if_decorator("curses")(func)
 

diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index bd8eea3d6f5a0..2cbc918ebbaeb 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 #
 # GNUWin32 uname gives "windows32" or "server version windows32" while
 # some versions of MSYS uname return "MSYS_NT*", but most environments
-# standardize on "Windows_NT", so we'll make it consistent here. 
+# standardize on "Windows_NT", so we'll make it consistent here.
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
@@ -210,6 +210,12 @@ else
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
DSYM = $(EXE).debug
endif
+
+   ifeq "$(MAKE_DWP)" "YES"
+   MAKE_DWO := YES
+   DWP_NAME = $(EXE).dwp
+   DYLIB_DWP_NAME = $(DYLIB_NAME).dwp
+   endif
 endif
 
 LIMIT_DEBUG_INFO_FLAGS =
@@ -358,6 +364,7 @@ ifneq "$(OS)" "Darwin"
 
OBJCOPY ?= $(call replace_cc_with,objcopy)
ARCHIVER ?= $(call replace_cc_with,ar)
+   DWP ?= $(call replace_cc_with,dwp)
override AR = $(ARCHIVER)
 endif
 
@@ -528,6 +535,10 @@ ifneq "$(CXX)" ""
endif
 endif
 
+ifeq "$(GEN_GNU_BUILD_ID)" "YES"
+   LDFLAGS += -Wl,--build-id
+endif
+
 #--
 # DYLIB_ONLY variable can be used to skip the building of a.out.
 # See the sections below regarding dSYM file as well as the building of
@@ -566,10 +577,17 @@ else
 endif
 else
 ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
+ifeq "$(SAVE_FULL_DEBUG_BINARY)" "YES"
+   cp "$(EXE)" "$(EXE).unstripped"
+endif
$(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)"
$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)"
 endif
+ifeq "$(MAKE_DWP)" "YES"
+   $(DWP) -o "$(DWP_NAME)" $(DWOS)
 endif
+endif
+
 
 #--

[Lldb-commits] [lldb] [lldb] Added Debuginfod tests and fixed a couple issues (PR #92572)

2024-05-22 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Remove DWARFDebugInfo DIERef footguns (PR #92894)

2024-05-22 Thread Felipe de Azevedo Piovezan via lldb-commits


@@ -195,17 +195,17 @@ void DebugNamesDWARFIndex::GetCompleteObjCClass(
 if (!ref)
   continue;
 
-DWARFUnit *cu = m_debug_info.GetUnit(*ref);
-if (!cu || !cu->Supports_DW_AT_APPLE_objc_complete_type()) {
-  incomplete_types.push_back(*ref);
-  continue;
-}
-
-DWARFDIE die = m_debug_info.GetDIE(*ref);
+SymbolFileDWARF &dwarf = *llvm::cast(
+m_module.GetSymbolFile()->GetBackingSymbolFile());

felipepiovezan wrote:

This concerns me a little because `GetSymbolFile()` can fail (and so does 
GetBackingSymbolFile), and we're doing this somewhat expensive operation inside 
a loop, even though they are loop invariant.

We can probably address both of these issues by hoisting this outside the loop, 
computing the range, early exiting if the range is empty, and then setting up 
the symbol file. Something like:

```
auto range = m_debug_names_up->equal_range(class_name.GetStringRef()
if (range.empty()) return;

auto *symbolfile = m_module.GetSymbolFile();
if (!symbolfile) ...
if (!backing symbol file)...

// maybe just wrap all the lines above into a helper function

for (const DebugNames::Entry &entry :
   m_debug_names_up->equal_range(class_name.GetStringRef())) {
...
```



```

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


[Lldb-commits] [lldb] [lldb] Remove DWARFDebugInfo DIERef footguns (PR #92894)

2024-05-22 Thread Felipe de Azevedo Piovezan via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Remove DWARFDebugInfo DIERef footguns (PR #92894)

2024-05-22 Thread Felipe de Azevedo Piovezan via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Remove DWARFDebugInfo DIERef footguns (PR #92894)

2024-05-22 Thread Felipe de Azevedo Piovezan via lldb-commits

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-22 Thread via lldb-commits

https://github.com/GeorgeHuyubo updated 
https://github.com/llvm/llvm-project/pull/92492

>From 11dda0b456880005695b6d1f195060788ad0edb7 Mon Sep 17 00:00:00 2001
From: George Hu 
Date: Tue, 14 May 2024 16:18:20 -0700
Subject: [PATCH] Read and store gnu build id from loaded core file

---
 .../Process/elf-core/ProcessElfCore.cpp   | 84 ++-
 .../Plugins/Process/elf-core/ProcessElfCore.h | 14 +++-
 2 files changed, 94 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
index 36812c27a5b6d..cc82d1c2b5132 100644
--- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp
@@ -11,6 +11,7 @@
 #include 
 #include 
 
+#include "Plugins/ObjectFile/ELF/ELFHeader.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleSpec.h"
 #include "lldb/Core/PluginManager.h"
@@ -250,6 +251,9 @@ Status ProcessElfCore::DoLoadCore() {
 }
   }
 
+  // Try to find gnu build id before we load the executable.
+  UpdateBuildIdForNTFileEntries();
+
   // Core files are useless without the main executable. See if we can locate
   // the main executable using data we found in the core file notes.
   lldb::ModuleSP exe_module_sp = GetTarget().GetExecutableModule();
@@ -258,6 +262,7 @@ Status ProcessElfCore::DoLoadCore() {
 if (!m_nt_file_entries.empty()) {
   ModuleSpec exe_module_spec;
   exe_module_spec.GetArchitecture() = arch;
+  exe_module_spec.GetUUID() = m_nt_file_entries[0].uuid;
   exe_module_spec.GetFileSpec().SetFile(m_nt_file_entries[0].path,
 FileSpec::Style::native);
   if (exe_module_spec.GetFileSpec()) {
@@ -271,6 +276,17 @@ Status ProcessElfCore::DoLoadCore() {
   return error;
 }
 
+void ProcessElfCore::UpdateBuildIdForNTFileEntries() {
+  if (!m_nt_file_entries.empty()) {
+for (NT_FILE_Entry &entry : m_nt_file_entries) {
+  std::optional uuid =
+  FindNoteInCoreMemory(entry.start, llvm::ELF::NT_GNU_BUILD_ID);
+  if (uuid)
+entry.uuid = uuid.value();
+}
+  }
+}
+
 lldb_private::DynamicLoader *ProcessElfCore::GetDynamicLoader() {
   if (m_dyld_up.get() == nullptr)
 m_dyld_up.reset(DynamicLoader::FindPlugin(
@@ -570,11 +586,13 @@ static void ParseOpenBSDProcInfo(ThreadData &thread_data,
 }
 
 llvm::Expected>
-ProcessElfCore::parseSegment(const DataExtractor &segment) {
+ProcessElfCore::parseSegment(const DataExtractor &segment,
+ unsigned long segment_size) {
   lldb::offset_t offset = 0;
   std::vector result;
-
-  while (offset < segment.GetByteSize()) {
+  unsigned long note_size =
+  segment_size == 0 ? segment.GetByteSize() : segment_size;
+  while (offset < note_size) {
 ELFNote note = ELFNote();
 if (!note.Parse(segment, &offset))
   return llvm::make_error(
@@ -983,6 +1001,66 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+bool ProcessElfCore::IsElf(lldb::addr_t address) {
+  uint8_t buf[4];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, 4, error);
+  if (byte_read != 4)
+return false;
+  return elf::ELFHeader::MagicBytesMatch(buf);
+}
+
+std::optional ProcessElfCore::FindNoteInCoreMemory(lldb::addr_t address,
+ uint32_t type) {
+  if (!IsElf(address))
+return std::nullopt;
+  const uint32_t addr_size = GetAddressByteSize();
+  const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr)
+: 
sizeof(llvm::ELF::Elf64_Ehdr);
+
+  unsigned char buf[4096];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, elf_header_size, error);
+  if (byte_read != elf_header_size)
+return std::nullopt;
+  DataExtractor data(buf, 4096, GetByteOrder(), addr_size);
+  lldb::offset_t offset = 0;
+
+  elf::ELFHeader elf_header;
+  elf_header.Parse(data, &offset);
+
+  const lldb::addr_t ph_addr = address + elf_header.e_phoff;
+
+  for (unsigned int i = 0; i < elf_header.e_phnum; ++i) {
+byte_read = ReadMemory(ph_addr + i * elf_header.e_phentsize, buf,
+   elf_header.e_phentsize, error);
+if (byte_read != elf_header.e_phentsize)
+  break;
+offset = 0;
+elf::ELFProgramHeader program_header;
+program_header.Parse(data, &offset);
+if (program_header.p_type != llvm::ELF::PT_NOTE)
+  continue;
+
+byte_read =
+ReadMemory(program_header.p_vaddr, buf, program_header.p_memsz, error);
+if (byte_read != program_header.p_memsz)
+  continue;
+
+auto notes_or_error = parseSegment(data, program_header.p_memsz);
+if (!notes_or_error)
+  return std::nullopt;
+for (const CoreNote ¬e : *notes_or_error) {
+  if (note.info.n_namesz == 4 && note.info.n_type == type) {
+if ("GNU" == note.info.n_name)
+  return UUID(llvm::Ar

[Lldb-commits] [lldb] [lldb/DWARF] Make sure bad abbreviation codes do not crash lldb (PR #93006)

2024-05-22 Thread Alex Langford via lldb-commits

https://github.com/bulbazord approved this pull request.


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


[Lldb-commits] [lldb] [lldb/DWARF] Make sure bad abbreviation codes do not crash lldb (PR #93006)

2024-05-22 Thread Jonas Devlieghere via lldb-commits


@@ -44,10 +45,20 @@ bool DWARFDebugInfoEntry::Extract(const DWARFDataExtractor 
&data,
   const DWARFUnit *cu,
   lldb::offset_t *offset_ptr) {
   m_offset = *offset_ptr;
+  auto report_error = [&](const char *fmt, const auto &...vals) {
+cu->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(

JDevlieghere wrote:

Can we assume `cu` is always a valid pointer? If so, should the signature take 
it by const reference instead? 

AFAIK only `GetAbbreviationDeclarationPtr` checks that it's not NULL but we 
have a code path that calls the lambda before as well as when `abbrevDecl` is 
NULL which would happen if CU is NULL. 

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


[Lldb-commits] [lldb] [lldb/DWARF] Make sure bad abbreviation codes do not crash lldb (PR #93006)

2024-05-22 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb/DWARF] Make sure bad abbreviation codes do not crash lldb (PR #93006)

2024-05-22 Thread Greg Clayton via lldb-commits

https://github.com/clayborg commented:

We have to back out the PeekDieName() patch locally at Meta because it was 
crashing us due to this assertion due to .debug_names tables having incorrect 
values for type units. Only one type unit will appear in the final file and 
type units can have differing contents for the same type. This means 
accelerator table entries from .o file that had a type unit, but its type unit 
didn't end up in the final output file, can be bogus and not point to valid DIE 
offsets which can cause PeekDieName to parse at random  offsets in a type unit 
and crash or report an error now. So we might need an extra bool to be passed 
to the `DWARFDebugInfoEntry::Extract(...)` function that says to report an 
error and have PeekDieName call this with "report_errors = false". Right now 
many of these entries will cause a large numver of errors to be reported. This 
is being fixed by verifying that type unit accelerator table entries are 
matched to the right type unit, but that PR isn't in yet.

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


[Lldb-commits] [lldb] [lldb] Fixed the TestDebuggerAPI test on x86_64 Windows host (PR #90580)

2024-05-22 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Added Debuginfod tests and fixed a couple issues (PR #92572)

2024-05-22 Thread Daniel Thornburgh via lldb-commits

mysterymath wrote:

This broke the Fuchsia CI builders' LLDB test suite:

https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8747217173107569041/overview

```
FAIL: LLDB (/b/s/w/ir/x/w/llvm_build/bin/clang-x86_64) :: 
test_normal_stripped_split_with_dwp 
(TestDebuginfodDWP.DebugInfodDWPTests.test_normal_stripped_split_with_dwp)
==
ERROR: test_debuginfod_both_okd_symfiles_from_service 
(TestDebuginfodDWP.DebugInfodDWPTests.test_debuginfod_both_okd_symfiles_from_service)
   Test behavior with both the only-keep-debug symbols and the dwp symbols
--
Error when building test subject.
```

```
==
ERROR: test_expr_dwarf 
(TestSharedLibStrippedSymbols.SharedLibStrippedTestCase.test_expr_dwarf)
   Test that types work when defined in a shared library and forwa/d-declared 
in the main executable
--
Error when building test subject.


...

ifeq "" "YES"
/bin/sh: 1: ifeq: not found
make: *** [Makefile.rules:631: libfoo.so] Error 127
make: Leaving directory 
'/b/s/w/ir/x/w/llvm_build/lldb-test-build.noindex/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.test_expr_dwarf'

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


[Lldb-commits] [lldb] Revert "[lldb] Added Debuginfod tests and fixed a couple issues" (PR #93094)

2024-05-22 Thread Daniel Thornburgh via lldb-commits

https://github.com/mysterymath created 
https://github.com/llvm/llvm-project/pull/93094

Reverts llvm/llvm-project#92572 due to Fuchsia CI breakages (using CLI tools in 
tests that weren't necessarily built).

>From daa63e1870999e8ca8db454a788a0720740d194a Mon Sep 17 00:00:00 2001
From: Daniel Thornburgh 
Date: Wed, 22 May 2024 13:54:32 -0700
Subject: [PATCH] Revert "[lldb] Added Debuginfod tests and fixed a couple
 issues (#92572)"

This reverts commit e558d21e87882d40e29d858b1269ee8f1ddf2a38.
---
 lldb/include/lldb/Host/Config.h.cmake |   2 -
 .../Python/lldbsuite/test/decorators.py   |   4 -
 .../Python/lldbsuite/test/make/Makefile.rules |  26 +--
 lldb/source/API/SBDebugger.cpp|  13 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  38 ++--
 .../Plugins/SymbolLocator/CMakeLists.txt  |   7 +-
 .../SymbolVendor/ELF/SymbolVendorELF.cpp  |  29 +--
 lldb/test/API/debuginfod/Normal/Makefile  |  19 --
 .../API/debuginfod/Normal/TestDebuginfod.py   | 186 -
 lldb/test/API/debuginfod/Normal/main.c|   7 -
 lldb/test/API/debuginfod/SplitDWARF/Makefile  |  23 --
 .../SplitDWARF/TestDebuginfodDWP.py   | 196 --
 lldb/test/API/debuginfod/SplitDWARF/main.c|   7 -
 13 files changed, 22 insertions(+), 535 deletions(-)
 delete mode 100644 lldb/test/API/debuginfod/Normal/Makefile
 delete mode 100644 lldb/test/API/debuginfod/Normal/TestDebuginfod.py
 delete mode 100644 lldb/test/API/debuginfod/Normal/main.c
 delete mode 100644 lldb/test/API/debuginfod/SplitDWARF/Makefile
 delete mode 100644 lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py
 delete mode 100644 lldb/test/API/debuginfod/SplitDWARF/main.c

diff --git a/lldb/include/lldb/Host/Config.h.cmake 
b/lldb/include/lldb/Host/Config.h.cmake
index 9e538534086a2..3defa454f6d42 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -33,8 +33,6 @@
 
 #cmakedefine01 LLDB_ENABLE_LZMA
 
-#cmakedefine01 LLVM_ENABLE_CURL
-
 #cmakedefine01 LLDB_ENABLE_CURSES
 
 #cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index b4ac3bdabac86..79cc0a2aeacbe 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1055,10 +1055,6 @@ def _get_bool_config_skip_if_decorator(key):
 return unittest.skipIf(not have, "requires " + key)
 
 
-def skipIfCurlSupportMissing(func):
-return _get_bool_config_skip_if_decorator("curl")(func)
-
-
 def skipIfCursesSupportMissing(func):
 return _get_bool_config_skip_if_decorator("curses")(func)
 
diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index 2cbc918ebbaeb..bd8eea3d6f5a0 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 #
 # GNUWin32 uname gives "windows32" or "server version windows32" while
 # some versions of MSYS uname return "MSYS_NT*", but most environments
-# standardize on "Windows_NT", so we'll make it consistent here.
+# standardize on "Windows_NT", so we'll make it consistent here. 
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
@@ -210,12 +210,6 @@ else
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
DSYM = $(EXE).debug
endif
-
-   ifeq "$(MAKE_DWP)" "YES"
-   MAKE_DWO := YES
-   DWP_NAME = $(EXE).dwp
-   DYLIB_DWP_NAME = $(DYLIB_NAME).dwp
-   endif
 endif
 
 LIMIT_DEBUG_INFO_FLAGS =
@@ -364,7 +358,6 @@ ifneq "$(OS)" "Darwin"
 
OBJCOPY ?= $(call replace_cc_with,objcopy)
ARCHIVER ?= $(call replace_cc_with,ar)
-   DWP ?= $(call replace_cc_with,dwp)
override AR = $(ARCHIVER)
 endif
 
@@ -535,10 +528,6 @@ ifneq "$(CXX)" ""
endif
 endif
 
-ifeq "$(GEN_GNU_BUILD_ID)" "YES"
-   LDFLAGS += -Wl,--build-id
-endif
-
 #--
 # DYLIB_ONLY variable can be used to skip the building of a.out.
 # See the sections below regarding dSYM file as well as the building of
@@ -577,17 +566,10 @@ else
 endif
 else
 ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
-ifeq "$(SAVE_FULL_DEBUG_BINARY)" "YES"
-   cp "$(EXE)" "$(EXE).unstripped"
-endif
$(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)"
$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)"
 endif
-ifeq "$(MAKE_DWP)" "YES"
-   $(DWP) -o "$(DWP_NAME)" $(DWOS)
 endif
-endif
-
 
 #--
 # Make the dylib
@@ -629,15 +611,9 @@ endif
 else
$(LD) 

[Lldb-commits] [lldb] Revert "[lldb] Added Debuginfod tests and fixed a couple issues" (PR #93094)

2024-05-22 Thread Daniel Thornburgh via lldb-commits

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


[Lldb-commits] [lldb] c93a670 - Revert "[lldb] Added Debuginfod tests and fixed a couple issues" (#93094)

2024-05-22 Thread via lldb-commits

Author: Daniel Thornburgh
Date: 2024-05-22T13:56:33-07:00
New Revision: c93a67038dcc1adeafa74e105fba02714732097a

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

LOG: Revert "[lldb] Added Debuginfod tests and fixed a couple issues" (#93094)

Reverts llvm/llvm-project#92572 due to Fuchsia CI breakages (using CLI
tools in tests that weren't necessarily built).

Added: 


Modified: 
lldb/include/lldb/Host/Config.h.cmake
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/make/Makefile.rules
lldb/source/API/SBDebugger.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolLocator/CMakeLists.txt
lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp

Removed: 
lldb/test/API/debuginfod/Normal/Makefile
lldb/test/API/debuginfod/Normal/TestDebuginfod.py
lldb/test/API/debuginfod/Normal/main.c
lldb/test/API/debuginfod/SplitDWARF/Makefile
lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py
lldb/test/API/debuginfod/SplitDWARF/main.c



diff  --git a/lldb/include/lldb/Host/Config.h.cmake 
b/lldb/include/lldb/Host/Config.h.cmake
index 9e538534086a2..3defa454f6d42 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -33,8 +33,6 @@
 
 #cmakedefine01 LLDB_ENABLE_LZMA
 
-#cmakedefine01 LLVM_ENABLE_CURL
-
 #cmakedefine01 LLDB_ENABLE_CURSES
 
 #cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H

diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index b4ac3bdabac86..79cc0a2aeacbe 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1055,10 +1055,6 @@ def _get_bool_config_skip_if_decorator(key):
 return unittest.skipIf(not have, "requires " + key)
 
 
-def skipIfCurlSupportMissing(func):
-return _get_bool_config_skip_if_decorator("curl")(func)
-
-
 def skipIfCursesSupportMissing(func):
 return _get_bool_config_skip_if_decorator("curses")(func)
 

diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index 2cbc918ebbaeb..bd8eea3d6f5a0 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 #
 # GNUWin32 uname gives "windows32" or "server version windows32" while
 # some versions of MSYS uname return "MSYS_NT*", but most environments
-# standardize on "Windows_NT", so we'll make it consistent here.
+# standardize on "Windows_NT", so we'll make it consistent here. 
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
@@ -210,12 +210,6 @@ else
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
DSYM = $(EXE).debug
endif
-
-   ifeq "$(MAKE_DWP)" "YES"
-   MAKE_DWO := YES
-   DWP_NAME = $(EXE).dwp
-   DYLIB_DWP_NAME = $(DYLIB_NAME).dwp
-   endif
 endif
 
 LIMIT_DEBUG_INFO_FLAGS =
@@ -364,7 +358,6 @@ ifneq "$(OS)" "Darwin"
 
OBJCOPY ?= $(call replace_cc_with,objcopy)
ARCHIVER ?= $(call replace_cc_with,ar)
-   DWP ?= $(call replace_cc_with,dwp)
override AR = $(ARCHIVER)
 endif
 
@@ -535,10 +528,6 @@ ifneq "$(CXX)" ""
endif
 endif
 
-ifeq "$(GEN_GNU_BUILD_ID)" "YES"
-   LDFLAGS += -Wl,--build-id
-endif
-
 #--
 # DYLIB_ONLY variable can be used to skip the building of a.out.
 # See the sections below regarding dSYM file as well as the building of
@@ -577,17 +566,10 @@ else
 endif
 else
 ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
-ifeq "$(SAVE_FULL_DEBUG_BINARY)" "YES"
-   cp "$(EXE)" "$(EXE).unstripped"
-endif
$(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)"
$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)"
 endif
-ifeq "$(MAKE_DWP)" "YES"
-   $(DWP) -o "$(DWP_NAME)" $(DWOS)
 endif
-endif
-
 
 #--
 # Make the dylib
@@ -629,15 +611,9 @@ endif
 else
$(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -shared -o "$(DYLIB_FILENAME)"
 ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
-   ifeq "$(SAVE_FULL_DEBUG_BINARY)" "YES"
-   cp "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).unstripped"
-   endif
$(OBJCOPY) --only-keep-debug "$(DYLIB_FILENAME)" 
"$(DYLIB_FILENAME).debug"
$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DYLIB_FILENAME).debug" 
"$(DYLIB_FILENAME)" "$(DYLIB_FILENAME)

[Lldb-commits] [lldb] Revert "[lldb] Added Debuginfod tests and fixed a couple issues" (PR #93094)

2024-05-22 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Daniel Thornburgh (mysterymath)


Changes

Reverts llvm/llvm-project#92572 due to Fuchsia CI breakages (using CLI 
tools in tests that weren't necessarily built).

---

Patch is 27.56 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/93094.diff


13 Files Affected:

- (modified) lldb/include/lldb/Host/Config.h.cmake (-2) 
- (modified) lldb/packages/Python/lldbsuite/test/decorators.py (-4) 
- (modified) lldb/packages/Python/lldbsuite/test/make/Makefile.rules (+1-25) 
- (modified) lldb/source/API/SBDebugger.cpp (+5-8) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+13-25) 
- (modified) lldb/source/Plugins/SymbolLocator/CMakeLists.txt (+1-6) 
- (modified) lldb/source/Plugins/SymbolVendor/ELF/SymbolVendorELF.cpp (+2-27) 
- (removed) lldb/test/API/debuginfod/Normal/Makefile (-19) 
- (removed) lldb/test/API/debuginfod/Normal/TestDebuginfod.py (-186) 
- (removed) lldb/test/API/debuginfod/Normal/main.c (-7) 
- (removed) lldb/test/API/debuginfod/SplitDWARF/Makefile (-23) 
- (removed) lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py (-196) 
- (removed) lldb/test/API/debuginfod/SplitDWARF/main.c (-7) 


``diff
diff --git a/lldb/include/lldb/Host/Config.h.cmake 
b/lldb/include/lldb/Host/Config.h.cmake
index 9e538534086a2..3defa454f6d42 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -33,8 +33,6 @@
 
 #cmakedefine01 LLDB_ENABLE_LZMA
 
-#cmakedefine01 LLVM_ENABLE_CURL
-
 #cmakedefine01 LLDB_ENABLE_CURSES
 
 #cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index b4ac3bdabac86..79cc0a2aeacbe 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1055,10 +1055,6 @@ def _get_bool_config_skip_if_decorator(key):
 return unittest.skipIf(not have, "requires " + key)
 
 
-def skipIfCurlSupportMissing(func):
-return _get_bool_config_skip_if_decorator("curl")(func)
-
-
 def skipIfCursesSupportMissing(func):
 return _get_bool_config_skip_if_decorator("curses")(func)
 
diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index 2cbc918ebbaeb..bd8eea3d6f5a0 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -51,7 +51,7 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 #
 # GNUWin32 uname gives "windows32" or "server version windows32" while
 # some versions of MSYS uname return "MSYS_NT*", but most environments
-# standardize on "Windows_NT", so we'll make it consistent here.
+# standardize on "Windows_NT", so we'll make it consistent here. 
 # When running tests from Visual Studio, the environment variable isn't
 # inherited all the way down to the process spawned for make.
 #--
@@ -210,12 +210,6 @@ else
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
DSYM = $(EXE).debug
endif
-
-   ifeq "$(MAKE_DWP)" "YES"
-   MAKE_DWO := YES
-   DWP_NAME = $(EXE).dwp
-   DYLIB_DWP_NAME = $(DYLIB_NAME).dwp
-   endif
 endif
 
 LIMIT_DEBUG_INFO_FLAGS =
@@ -364,7 +358,6 @@ ifneq "$(OS)" "Darwin"
 
OBJCOPY ?= $(call replace_cc_with,objcopy)
ARCHIVER ?= $(call replace_cc_with,ar)
-   DWP ?= $(call replace_cc_with,dwp)
override AR = $(ARCHIVER)
 endif
 
@@ -535,10 +528,6 @@ ifneq "$(CXX)" ""
endif
 endif
 
-ifeq "$(GEN_GNU_BUILD_ID)" "YES"
-   LDFLAGS += -Wl,--build-id
-endif
-
 #--
 # DYLIB_ONLY variable can be used to skip the building of a.out.
 # See the sections below regarding dSYM file as well as the building of
@@ -577,17 +566,10 @@ else
 endif
 else
 ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
-ifeq "$(SAVE_FULL_DEBUG_BINARY)" "YES"
-   cp "$(EXE)" "$(EXE).unstripped"
-endif
$(OBJCOPY) --only-keep-debug "$(EXE)" "$(DSYM)"
$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DSYM)" "$(EXE)" "$(EXE)"
 endif
-ifeq "$(MAKE_DWP)" "YES"
-   $(DWP) -o "$(DWP_NAME)" $(DWOS)
 endif
-endif
-
 
 #--
 # Make the dylib
@@ -629,15 +611,9 @@ endif
 else
$(LD) $(DYLIB_OBJECTS) $(LDFLAGS) -shared -o "$(DYLIB_FILENAME)"
 ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
-   ifeq "$(SAVE_FULL_DEBUG_BINARY)" "YES"
-   cp "$(DYLIB_FILENAME)" "$(DYLIB_FILENAME).unstripped"
-   endif
$(OBJCOPY) --only-keep-debug "$(DYLIB_FILENAME)" 
"$(DYLIB_FILENAME).debug"
$(OBJCOPY) --strip-debug --add-gnu-debuglink="$(DYLIB_FILENAME).debug" 
"$(DYLIB_FILENAME)" "$(DYLIB_FILENAME)"
 endif
-ifeq "$(MAKE_DWP)" "YES"
-  

[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)

2024-05-22 Thread via lldb-commits


@@ -1312,10 +1312,16 @@ class Process : public 
std::enable_shared_from_this,
 
   size_t GetThreadStatus(Stream &ostrm, bool only_threads_with_stop_reason,
  uint32_t start_frame, uint32_t num_frames,
- uint32_t num_frames_with_source,
- bool stop_format);
+ uint32_t num_frames_with_source, bool stop_format);
 
-  void SendAsyncInterrupt();
+  /// Send an async interrupt request.
+  ///
+  /// If \a thread is specified the async interrupt stop will be attributed the

jimingham wrote:

"will be attributed to the" - missing "to"

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


[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)

2024-05-22 Thread via lldb-commits


@@ -1312,10 +1312,16 @@ class Process : public 
std::enable_shared_from_this,
 
   size_t GetThreadStatus(Stream &ostrm, bool only_threads_with_stop_reason,
  uint32_t start_frame, uint32_t num_frames,
- uint32_t num_frames_with_source,
- bool stop_format);
+ uint32_t num_frames_with_source, bool stop_format);
 
-  void SendAsyncInterrupt();
+  /// Send an async interrupt request.
+  ///
+  /// If \a thread is specified the async interrupt stop will be attributed the
+  /// specified thread.
+  ///
+  /// \param[in] thread
+  /// The thread from which to attribute the async interrupt stop to.

jimingham wrote:

"The thread the async interrupt will be attributed to" 

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


[Lldb-commits] [clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-22 Thread Vlad Serebrennikov via lldb-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/92953

>From 66e05ac24613435dbe774d49684d8ff9d119c4c3 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 21 May 2024 21:41:24 +0300
Subject: [PATCH 1/3] Remove some `try_compile` CMake checks for compiler flags

This patch remove 36 checks for compiler flags that are done via invoking the 
compiler across LLVM, Clang, and LLDB. It's was made possible by raising the 
bar for supported compilers that has been happening over the years since the 
checks were added.

This is going to improve CMake configuration times. This topic was highlighted 
in 
https://discourse.llvm.org/t/cmake-compiler-flag-checks-are-really-slow-ideas-to-speed-them-up/78882.
---
 clang/CMakeLists.txt  |   5 +-
 .../tests/functional/exec/CMakeLists.txt  |   6 +-
 lldb/cmake/modules/LLDBConfig.cmake   |  20 +--
 llvm/cmake/config-ix.cmake|  19 +--
 llvm/cmake/modules/AddLLVM.cmake  |   4 +-
 llvm/cmake/modules/HandleLLVMOptions.cmake| 142 --
 third-party/unittest/CMakeLists.txt   |   4 +-
 7 files changed, 80 insertions(+), 120 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index c20ce47a12abb..a6bcb853a464c 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -349,10 +349,7 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-long-long")
   endif ()
 
-  check_cxx_compiler_flag("-Werror -Wnested-anon-types" 
CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG)
-  if( CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG )
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
-  endif()
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" )
 endif ()
 
 # Determine HOST_LINK_VERSION on Darwin.
diff --git a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt 
b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
index 95c6fdb610e0f..cb6ebda183725 100644
--- a/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
+++ b/clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt
@@ -2,11 +2,7 @@ project(exec C)
 
 cmake_minimum_required(VERSION 3.20.0)
 
-include(CheckCCompilerFlag)
-check_c_compiler_flag("-std=c99" C99_SUPPORTED)
-if (C99_SUPPORTED)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
-endif()
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
 
 include(CheckFunctionExists)
 include(CheckSymbolExists)
diff --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 3c6223b015bb1..6458f2e174643 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -187,24 +187,18 @@ 
include_directories("${CMAKE_CURRENT_BINARY_DIR}/../clang/include")
 # form -W, and if supported, add the corresponding -Wno- option.
 
 # Disable GCC warnings
-check_cxx_compiler_flag("-Wdeprecated-declarations" 
CXX_SUPPORTS_DEPRECATED_DECLARATIONS)
-append_if(CXX_SUPPORTS_DEPRECATED_DECLARATIONS "-Wno-deprecated-declarations" 
CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wunknown-pragmas" CXX_SUPPORTS_UNKNOWN_PRAGMAS)
-append_if(CXX_SUPPORTS_UNKNOWN_PRAGMAS "-Wno-unknown-pragmas" CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wstrict-aliasing" CXX_SUPPORTS_STRICT_ALIASING)
-append_if(CXX_SUPPORTS_STRICT_ALIASING "-Wno-strict-aliasing" CMAKE_CXX_FLAGS)
+append("-Wno-deprecated-declarations" CMAKE_CXX_FLAGS)
+append("-Wno-unknown-pragmas" CMAKE_CXX_FLAGS)
+append("-Wno-strict-aliasing" CMAKE_CXX_FLAGS)
 
 check_cxx_compiler_flag("-Wstringop-truncation" 
CXX_SUPPORTS_STRINGOP_TRUNCATION)
 append_if(CXX_SUPPORTS_STRINGOP_TRUNCATION "-Wno-stringop-truncation" 
CMAKE_CXX_FLAGS)
 
 # Disable Clang warnings
-check_cxx_compiler_flag("-Wdeprecated-register" 
CXX_SUPPORTS_DEPRECATED_REGISTER)
-append_if(CXX_SUPPORTS_DEPRECATED_REGISTER "-Wno-deprecated-register" 
CMAKE_CXX_FLAGS)
-
-check_cxx_compiler_flag("-Wvla-extension" CXX_SUPPORTS_VLA_EXTENSION)
-append_if(CXX_SUPPORTS_VLA_EXTENSION "-Wno-vla-extension" CMAKE_CXX_FLAGS)
+if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  append("-Wno-deprecated-register" CMAKE_CXX_FLAGS)
+  append("-Wno-vla-extension" CMAKE_CXX_FLAGS)
+endif()
 
 # Disable MSVC warnings
 if( MSVC )
diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index bf1b110245bb2..0900e1107076e 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -415,15 +415,14 @@ if( LLVM_ENABLE_PIC )
   set(ENABLE_PIC 1)
 else()
   set(ENABLE_PIC 0)
-  check_cxx_compiler_flag("-fno-pie" SUPPORTS_NO_PIE_FLAG)
-  if(SUPPORTS_NO_PIE_FLAG)
-set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie")
-  endif()
+  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-pie")
 endif()
 
-check_cxx_compiler_flag("-Wvariadic-macros" SUPPORTS_VARIADIC_MACROS_FLAG)
-check_cxx_compiler_flag("-Wgnu-zero-variadic-macro-arguments"
-SUPPORTS_GNU_ZERO_VA

[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-22 Thread Greg Clayton via lldb-commits


@@ -983,6 +1001,66 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+bool ProcessElfCore::IsElf(lldb::addr_t address) {
+  uint8_t buf[4];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, 4, error);
+  if (byte_read != 4)
+return false;
+  return elf::ELFHeader::MagicBytesMatch(buf);
+}
+
+std::optional ProcessElfCore::FindNoteInCoreMemory(lldb::addr_t address,
+ uint32_t type) {
+  if (!IsElf(address))
+return std::nullopt;
+  const uint32_t addr_size = GetAddressByteSize();
+  const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr)
+: 
sizeof(llvm::ELF::Elf64_Ehdr);
+
+  unsigned char buf[4096];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, elf_header_size, error);
+  if (byte_read != elf_header_size)
+return std::nullopt;
+  DataExtractor data(buf, 4096, GetByteOrder(), addr_size);

clayborg wrote:

It is ok to have a large buffer, but we should make sure the data extractor 
points to just the data we have read for each place that we use it by 
contructing new DataExtractor objects:
```
assert(sizeof(buf) >= elf_header_size);
DataExtractor header_data(buf, elf_header_size, GetByteOrder(), addr_size);
```


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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-22 Thread Greg Clayton via lldb-commits


@@ -167,7 +178,8 @@ class ProcessElfCore : public 
lldb_private::PostMortemProcess {
   AddAddressRangeFromMemoryTagSegment(const elf::ELFProgramHeader &header);
 
   llvm::Expected>
-  parseSegment(const lldb_private::DataExtractor &segment);
+  parseSegment(const lldb_private::DataExtractor &segment,
+   unsigned long segment_size = 0);

clayborg wrote:

revert

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-22 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-22 Thread Greg Clayton via lldb-commits


@@ -117,6 +117,7 @@ class ProcessElfCore : public 
lldb_private::PostMortemProcess {
 lldb::addr_t end;
 lldb::addr_t file_ofs;
 std::string path;
+lldb_private::UUID uuid; //.note.gnu.build-id

clayborg wrote:

Add a comment letting the user know the UUID isn't actually in the 
NT_FILE_Entry:
```
// Add a UUID member for convenient access. The UUID value is not in the 
NT_FILE entries,
// we will find it in core memory and store it here for easy access.
```

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-22 Thread Greg Clayton via lldb-commits

https://github.com/clayborg requested changes to this pull request.


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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-22 Thread Greg Clayton via lldb-commits


@@ -983,6 +1001,66 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+bool ProcessElfCore::IsElf(lldb::addr_t address) {
+  uint8_t buf[4];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, 4, error);
+  if (byte_read != 4)
+return false;
+  return elf::ELFHeader::MagicBytesMatch(buf);
+}
+
+std::optional ProcessElfCore::FindNoteInCoreMemory(lldb::addr_t address,
+ uint32_t type) {
+  if (!IsElf(address))
+return std::nullopt;
+  const uint32_t addr_size = GetAddressByteSize();
+  const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr)
+: 
sizeof(llvm::ELF::Elf64_Ehdr);
+
+  unsigned char buf[4096];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, elf_header_size, error);
+  if (byte_read != elf_header_size)
+return std::nullopt;
+  DataExtractor data(buf, 4096, GetByteOrder(), addr_size);
+  lldb::offset_t offset = 0;
+
+  elf::ELFHeader elf_header;
+  elf_header.Parse(data, &offset);
+
+  const lldb::addr_t ph_addr = address + elf_header.e_phoff;
+
+  for (unsigned int i = 0; i < elf_header.e_phnum; ++i) {
+byte_read = ReadMemory(ph_addr + i * elf_header.e_phentsize, buf,
+   elf_header.e_phentsize, error);
+if (byte_read != elf_header.e_phentsize)
+  break;
+offset = 0;
+elf::ELFProgramHeader program_header;
+program_header.Parse(data, &offset);
+if (program_header.p_type != llvm::ELF::PT_NOTE)
+  continue;
+
+byte_read =
+ReadMemory(program_header.p_vaddr, buf, program_header.p_memsz, error);

clayborg wrote:

Make a dynamic memory buffer to make sure we have enough bytes to store the 
note data as it could exceed 4096 bytes, and then read into this buffer:
```
std::vector note_bytes;
note_bytes.resize(program_header.p_memsz);
byte_read =
ReadMemory(note_bytes.data(), note_bytes.size(), 
program_header.p_memsz, error);
```

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-22 Thread Greg Clayton via lldb-commits


@@ -983,6 +1001,66 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+bool ProcessElfCore::IsElf(lldb::addr_t address) {
+  uint8_t buf[4];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, 4, error);
+  if (byte_read != 4)
+return false;
+  return elf::ELFHeader::MagicBytesMatch(buf);
+}
+
+std::optional ProcessElfCore::FindNoteInCoreMemory(lldb::addr_t address,
+ uint32_t type) {
+  if (!IsElf(address))
+return std::nullopt;
+  const uint32_t addr_size = GetAddressByteSize();
+  const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr)
+: 
sizeof(llvm::ELF::Elf64_Ehdr);
+
+  unsigned char buf[4096];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, elf_header_size, error);
+  if (byte_read != elf_header_size)
+return std::nullopt;
+  DataExtractor data(buf, 4096, GetByteOrder(), addr_size);
+  lldb::offset_t offset = 0;
+
+  elf::ELFHeader elf_header;
+  elf_header.Parse(data, &offset);

clayborg wrote:

Use `header_data` to only allow access to the bytes we read.
```
elf_header.Parse(header_data, &offset);
```



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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-22 Thread Greg Clayton via lldb-commits


@@ -570,11 +586,13 @@ static void ParseOpenBSDProcInfo(ThreadData &thread_data,
 }
 
 llvm::Expected>
-ProcessElfCore::parseSegment(const DataExtractor &segment) {
+ProcessElfCore::parseSegment(const DataExtractor &segment,
+ unsigned long segment_size) {

clayborg wrote:

Remove thuis change, we can easily trim down the size of the DataExtractor 
before passing it in. See inline comments below.

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-22 Thread Greg Clayton via lldb-commits


@@ -983,6 +1001,66 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+bool ProcessElfCore::IsElf(lldb::addr_t address) {
+  uint8_t buf[4];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, 4, error);
+  if (byte_read != 4)
+return false;
+  return elf::ELFHeader::MagicBytesMatch(buf);
+}
+
+std::optional ProcessElfCore::FindNoteInCoreMemory(lldb::addr_t address,
+ uint32_t type) {
+  if (!IsElf(address))
+return std::nullopt;
+  const uint32_t addr_size = GetAddressByteSize();
+  const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr)
+: 
sizeof(llvm::ELF::Elf64_Ehdr);
+
+  unsigned char buf[4096];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, elf_header_size, error);
+  if (byte_read != elf_header_size)
+return std::nullopt;
+  DataExtractor data(buf, 4096, GetByteOrder(), addr_size);
+  lldb::offset_t offset = 0;
+
+  elf::ELFHeader elf_header;
+  elf_header.Parse(data, &offset);
+
+  const lldb::addr_t ph_addr = address + elf_header.e_phoff;
+
+  for (unsigned int i = 0; i < elf_header.e_phnum; ++i) {
+byte_read = ReadMemory(ph_addr + i * elf_header.e_phentsize, buf,
+   elf_header.e_phentsize, error);
+if (byte_read != elf_header.e_phentsize)
+  break;
+offset = 0;
+elf::ELFProgramHeader program_header;
+program_header.Parse(data, &offset);

clayborg wrote:

Create a `DataExtractor` that contains only a program header worth of data:
```
assert(sizeof(buf) >= elf_header.e_phentsize);
DataExtractor phdr_data(buf, elf_header.e_phentsize, GetByteOrder(), addr_size);
program_header.Parse(phdr_data, &offset);
```


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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-22 Thread Greg Clayton via lldb-commits


@@ -983,6 +1001,66 @@ llvm::Error 
ProcessElfCore::ParseThreadContextsFromNoteSegment(
   }
 }
 
+bool ProcessElfCore::IsElf(lldb::addr_t address) {
+  uint8_t buf[4];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, 4, error);
+  if (byte_read != 4)
+return false;
+  return elf::ELFHeader::MagicBytesMatch(buf);
+}
+
+std::optional ProcessElfCore::FindNoteInCoreMemory(lldb::addr_t address,
+ uint32_t type) {
+  if (!IsElf(address))
+return std::nullopt;
+  const uint32_t addr_size = GetAddressByteSize();
+  const size_t elf_header_size = addr_size == 4 ? sizeof(llvm::ELF::Elf32_Ehdr)
+: 
sizeof(llvm::ELF::Elf64_Ehdr);
+
+  unsigned char buf[4096];
+  Status error;
+  size_t byte_read = ReadMemory(address, buf, elf_header_size, error);
+  if (byte_read != elf_header_size)
+return std::nullopt;
+  DataExtractor data(buf, 4096, GetByteOrder(), addr_size);
+  lldb::offset_t offset = 0;
+
+  elf::ELFHeader elf_header;
+  elf_header.Parse(data, &offset);
+
+  const lldb::addr_t ph_addr = address + elf_header.e_phoff;
+
+  for (unsigned int i = 0; i < elf_header.e_phnum; ++i) {
+byte_read = ReadMemory(ph_addr + i * elf_header.e_phentsize, buf,
+   elf_header.e_phentsize, error);
+if (byte_read != elf_header.e_phentsize)
+  break;
+offset = 0;
+elf::ELFProgramHeader program_header;
+program_header.Parse(data, &offset);
+if (program_header.p_type != llvm::ELF::PT_NOTE)
+  continue;
+
+byte_read =
+ReadMemory(program_header.p_vaddr, buf, program_header.p_memsz, error);
+if (byte_read != program_header.p_memsz)
+  continue;
+
+auto notes_or_error = parseSegment(data, program_header.p_memsz);

clayborg wrote:

Create a DataBuffer for only the note data, and then we won't need to pass the 
`program_header.p_memsz` to `parseSegment(...)`:
```
DataExtractor note_data(note_bytes.data(), note_bytes.size(), GetByteOrder(), 
addr_size);
auto notes_or_error = parseSegment(note_data);
```

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


[Lldb-commits] [lldb] Read and store gnu build id from loaded core file (PR #92492)

2024-05-22 Thread Greg Clayton via lldb-commits


@@ -570,11 +586,13 @@ static void ParseOpenBSDProcInfo(ThreadData &thread_data,
 }
 
 llvm::Expected>
-ProcessElfCore::parseSegment(const DataExtractor &segment) {
+ProcessElfCore::parseSegment(const DataExtractor &segment,
+ unsigned long segment_size) {
   lldb::offset_t offset = 0;
   std::vector result;
-
-  while (offset < segment.GetByteSize()) {
+  unsigned long note_size =
+  segment_size == 0 ? segment.GetByteSize() : segment_size;
+  while (offset < note_size) {

clayborg wrote:

revert this, we will trim the size of the data down before passing it in.

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


[Lldb-commits] [clang] [compiler-rt] [libc] [libclc] [libcxxabi] [lld] [lldb] [llvm] [mlir] Add clarifying parenthesis around non-trivial conditions in ternary expressions. (PR #90391)

2024-05-22 Thread Fangrui Song via lldb-commits


@@ -801,7 +801,7 @@ static OutputDesc 
*addInputSec(StringMap> &map,
   auto *firstIsec = cast(
   cast(sec->commands[0])->sectionBases[0]);
   OutputSection *firstIsecOut =
-  firstIsec->flags & SHF_LINK_ORDER

MaskRay wrote:

A CppCheck issue may or may not be useful for the project. Projects have 
different code styles. Applying a random static analyzer report may not be 
useful.

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


[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)

2024-05-22 Thread via lldb-commits


@@ -0,0 +1,96 @@
+//===-- ThreadPlanSingleThreadTimeout.h -*- C++ 
-*-===//
+//
+// 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
+//
+//===--===//
+
+#ifndef LLDB_TARGET_THREADPLANSINGLETHREADTIMEOUT_H
+#define LLDB_TARGET_THREADPLANSINGLETHREADTIMEOUT_H
+
+#include "lldb/Target/Thread.h"
+#include "lldb/Target/ThreadPlan.h"
+#include "lldb/Utility/Event.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/State.h"
+
+#include 
+
+namespace lldb_private {
+
+//
+// Thread plan used by single thread execution to issue timeout. This is useful
+// to detect potential deadlock in single thread execution. The timeout 
measures
+// the elapsed time from the last internal stop and gets reset by each internal
+// stop to ensure we are accurately detecting execution not moving forward.
+// This means this thread plan may be created/destroyed multiple times by the
+// parent execution plan.
+//
+// When timeout happens, the thread plan resolves the potential deadlock by
+// issuing a thread specific async interrupt to enter stop state, then all
+// threads execution are resumed to resolve the potential deadlock.
+//
+class ThreadPlanSingleThreadTimeout : public ThreadPlan {
+  enum class State {
+WaitTimeout,// Waiting for timeout.
+AsyncInterrupt, // Async interrupt has been issued.
+Done,   // Finished resume all threads.
+  };
+
+public:
+  struct TimeoutInfo {
+ThreadPlanSingleThreadTimeout *m_instance = nullptr;
+ThreadPlanSingleThreadTimeout::State m_last_state = State::WaitTimeout;
+  };
+
+  ~ThreadPlanSingleThreadTimeout() override;
+
+  // Create a new instance from fresh new state.

jimingham wrote:

Since this API doesn't return the Created thread plan, then this API has to do 
more than just create it - it also pushes the plan, and sometimes doesn't.  So 
CreateNew is not a good name, and the description of what the function does is 
too abbreviated.

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


[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)

2024-05-22 Thread via lldb-commits


@@ -42,8 +45,13 @@ class ThreadPlanStepOverRange : public ThreadPlanStepRange,
 
   void SetupAvoidNoDebug(LazyBool step_out_avoids_code_without_debug_info);
   bool IsEquivalentContext(const SymbolContext &context);
+  // Clear and create a new ThreadPlanSingleThreadTimeout to detect if program

jimingham wrote:

ThreadPlanStepOverRange isn't the only thread plan that we want to have this 
behavior for.  For instance, it would be great to do this for 
ThreadPlanStepOut, which we don't even try to run on one thread, IIRC, and in 
order not to duplicate code, we will want to switch the 
ThreadPlanCallUserExpression over to this method as well.  So the code to 
handle the interrupt has to be shareable - maybe a mix-in class that does the 
management of the interrupt?

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


[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)

2024-05-22 Thread via lldb-commits


@@ -440,6 +440,12 @@ class ProcessGDBRemote : public Process,
   void HandleStopReply() override;
   void HandleAsyncStructuredDataPacket(llvm::StringRef data) override;
 
+  // Handle thread specific async interrupt and return the original thread
+  // that requested the async interrupt. It can be null if original thread
+  // has exited.
+  lldb::ThreadSP HandleThreadAsyncInterrupt(uint8_t signo,

jimingham wrote:

I can't see any reason why the ability to manage this interrupt event is 
GDBRemote specific.  So this should be a virtual method in Process, and 
overridden here.

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


[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)

2024-05-22 Thread via lldb-commits


@@ -3905,9 +3911,14 @@ thread_result_t Process::RunPrivateStateThread(bool 
is_secondary_thread) {
 
   if (interrupt_requested) {
 if (StateIsStoppedState(internal_state, true)) {
-  // We requested the interrupt, so mark this as such in the stop event
-  // so clients can tell an interrupted process from a natural stop
-  ProcessEventData::SetInterruptedInEvent(event_sp.get(), true);
+  // Oly mark interrupt event if it is not thread specific async

jimingham wrote:

Only

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


[Lldb-commits] [lldb] New ThreadPlanSingleThreadTimeout to resolve potential deadlock in single thread stepping (PR #90930)

2024-05-22 Thread via lldb-commits


@@ -1125,6 +1125,38 @@ class StopInfoUnixSignal : public StopInfo {
   std::optional m_code;
 };
 
+// StopInfoInterrupt
+
+class StopInfoInterrupt : public StopInfo {
+public:
+  StopInfoInterrupt(Thread &thread, int signo, const char *description)
+  : StopInfo(thread, signo) {
+SetDescription(description);
+  }
+
+  ~StopInfoInterrupt() override = default;
+
+  StopReason GetStopReason() const override {
+return lldb::eStopReasonInterrupt;
+  }
+
+  bool ShouldStopSynchronous(Event *event_ptr) override { return true; }
+
+  bool ShouldStop(Event *event_ptr) override {
+ThreadSP thread_sp(m_thread_wp.lock());
+if (thread_sp)
+  return thread_sp->GetProcess()->GetUnixSignals()->GetShouldStop(m_value);

jimingham wrote:

I don't think this is right.  This is a signal that you are using to implement 
your async interrupt.  So you shouldn't be governed by whether the user would 
or would not want to stop for that signal if it had been generated by some 
other means.

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


[Lldb-commits] [lldb] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

2024-05-22 Thread Alexander Yermolovich via lldb-commits

ayermolo wrote:

Using example above, with a fix by @dwblaikie 

I see:

```
 Hash: 0xE0CDC6A2
  String: 0x0018 "InnerState"
  Entry @ 0x10b {
Abbrev: 0x3
Tag: DW_TAG_class_type
DW_IDX_type_unit: 0x01
DW_IDX_die_offset: 0x0030
  }
```

Since clang no longer emits entry for:
```
0x0057:   DW_TAG_structure_type
DW_AT_declaration (true)
DW_AT_signature (0xe742f49eeadc2244)
```


Is this the right behavior?
Current BOLT behavior is to skip that DIE and reference it's parent:

```
Hash: 0xE0CDC6A2
  String: 0x0018 "InnerState"
  Entry @ 0x109 {
Abbrev: 0x3
Tag: DW_TAG_class_type
DW_IDX_type_unit: 0x01
DW_IDX_die_offset: 0x0030
DW_IDX_parent: Entry @ 0x147
  }
Entry @ 0x147 {
Abbrev: 0x7
Tag: DW_TAG_namespace
DW_IDX_type_unit: 0x01
DW_IDX_die_offset: 0x0025
DW_IDX_parent: Entry @ 0x126
  }
```

```
0x0055: DW_TAG_namespace
  DW_AT_name  ("B")

0x0057:   DW_TAG_structure_type
DW_AT_declaration (true)
DW_AT_signature (0xe742f49eeadc2244)

0x0060: DW_TAG_class_type
  DW_AT_calling_convention  (DW_CC_pass_by_value)
  DW_AT_name  ("InnerState")
  DW_AT_byte_size (0x01)
  DW_AT_decl_file ("/main.cpp")
  DW_AT_decl_line (1)

```

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


[Lldb-commits] [lldb] [lldb] Fixed the TestExitDuringExpression test in case of a remote target (PR #93119)

2024-05-22 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman created 
https://github.com/llvm/llvm-project/pull/93119

Sometimes this test failed on the assert `The thread exited` in case of a 
remote target. Increase the timeout to 1 second to avoid a racing condition.

>From c51c200295425167d664197bc4c15d02ec91ed09 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 23 May 2024 04:56:26 +0400
Subject: [PATCH] [lldb] Fixed the TestExitDuringExpression test in case of a
 remote target

Sometimes this test failed on the assert `The thread exited` in case of a 
remote target. Increase the timeout to 1 second to avoid a racing condition.
---
 .../API/functionalities/thread/exit_during_expression/main.c| 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/test/API/functionalities/thread/exit_during_expression/main.c 
b/lldb/test/API/functionalities/thread/exit_during_expression/main.c
index eb6d17520986c..f633632e96cc4 100644
--- a/lldb/test/API/functionalities/thread/exit_during_expression/main.c
+++ b/lldb/test/API/functionalities/thread/exit_during_expression/main.c
@@ -3,7 +3,7 @@
 #include 
 #include 
 
-static unsigned int g_timeout = 10;
+static unsigned int g_timeout = 100;
 
 extern int usleep(unsigned int);
 

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


[Lldb-commits] [lldb] [lldb] Fixed the TestExitDuringExpression test in case of a remote target (PR #93119)

2024-05-22 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

Sometimes this test failed on the assert `The thread exited` in case of a 
remote target. Increase the timeout to 1 second to avoid a racing condition.

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


1 Files Affected:

- (modified) lldb/test/API/functionalities/thread/exit_during_expression/main.c 
(+1-1) 


``diff
diff --git a/lldb/test/API/functionalities/thread/exit_during_expression/main.c 
b/lldb/test/API/functionalities/thread/exit_during_expression/main.c
index eb6d17520986c..f633632e96cc4 100644
--- a/lldb/test/API/functionalities/thread/exit_during_expression/main.c
+++ b/lldb/test/API/functionalities/thread/exit_during_expression/main.c
@@ -3,7 +3,7 @@
 #include 
 #include 
 
-static unsigned int g_timeout = 10;
+static unsigned int g_timeout = 100;
 
 extern int usleep(unsigned int);
 

``




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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the TestBreakpointCommand test (PR #93122)

2024-05-22 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman created 
https://github.com/llvm/llvm-project/pull/93122

The TestBreakpointCommand test is incorrectly disabled for Windows target. We 
can disable it for Windows host instead or just fix the issue. This patch fixes 
the path separator in BreakpointResolverFileLine::DeduceSourceMapping() and the 
Windows specific absolute path in the test in case of the Windows host.

>From 4220b6d0dcc32e26a6916608ad2b2cf873bee212 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 23 May 2024 05:30:39 +0400
Subject: [PATCH] [lldb] Fixed the TestBreakpointCommand test

The TestBreakpointCommand test is incorrectly disabled for Windows target. We 
can disable it for Windows host instead or just fix the issue. This patch fixes 
the path separator in BreakpointResolverFileLine::DeduceSourceMapping() and the 
Windows specific absolute path in the test in case of the Windows host.
---
 .../Breakpoint/BreakpointResolverFileLine.cpp  | 10 +-
 .../TestBreakpointCommand.py   | 18 +-
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp 
b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
index d7d8c714867e3..16c4ee1b88d16 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -198,16 +198,16 @@ void BreakpointResolverFileLine::DeduceSourceMapping(
 return;
 
   Log *log = GetLog(LLDBLog::Breakpoints);
-  const llvm::StringRef path_separator = llvm::sys::path::get_separator(
-  m_location_spec.GetFileSpec().GetPathStyle());
   // Check if "b" is a suffix of "a".
   // And return std::nullopt if not or the new path
   // of "a" after consuming "b" from the back.
   auto check_suffix =
-  [path_separator](llvm::StringRef a, llvm::StringRef b,
-   bool case_sensitive) -> std::optional {
+  [](llvm::StringRef a, llvm::StringRef b,
+ bool case_sensitive) -> std::optional {
 if (case_sensitive ? a.consume_back(b) : a.consume_back_insensitive(b)) {
-  if (a.empty() || a.ends_with(path_separator)) {
+  // Note sc_file_dir and request_file_dir below are normalized
+  // and always contain the path separator '/'.
+  if (a.empty() || a.ends_with("/")) {
 return a;
   }
 }
diff --git 
a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
 
b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
index c219a4ee5bd9c..605561c757372 100644
--- 
a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
+++ 
b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
@@ -6,7 +6,7 @@
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
+from lldbsuite.test import lldbutil, lldbplatformutil
 import json
 import os
 import side_effect
@@ -581,7 +581,6 @@ def verify_source_map_deduce_statistics(self, target, 
expected_count):
 self.assertNotEqual(target_stats, None)
 self.assertEqual(target_stats["sourceMapDeduceCount"], expected_count)
 
-@skipIf(oslist=["windows"])
 @no_debug_info_test
 def test_breakpoints_auto_source_map_relative(self):
 """
@@ -612,8 +611,13 @@ def test_breakpoints_auto_source_map_relative(self):
 self.verify_source_map_deduce_statistics(target, 0)
 
 # Verify auto deduced source map when file path in debug info
-# is a suffix of request breakpoint file path
-path = "/x/y/a/b/c/main.cpp"
+# is a suffix of request breakpoint file path.
+# Note the path must be absolute.
+path = (
+"/x/y/a/b/c/main.cpp"
+if lldbplatformutil.getHostPlatform() != "windows"
+else r"C:\x\y\a\b\c\main.cpp"
+)
 bp = target.BreakpointCreateByLocation(path, 2)
 self.assertGreater(
 bp.GetNumLocations(),
@@ -625,7 +629,11 @@ def test_breakpoints_auto_source_map_relative(self):
 
 source_map_json = self.get_source_map_json()
 self.assertEqual(len(source_map_json), 1, "source map should not be 
empty")
-self.verify_source_map_entry_pair(source_map_json[0], ".", "/x/y")
+self.verify_source_map_entry_pair(
+source_map_json[0],
+".",
+"/x/y" if lldbplatformutil.getHostPlatform() != "windows" else 
r"C:\x\y",
+)
 self.verify_source_map_deduce_statistics(target, 1)
 
 # Reset source map.

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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the TestBreakpointCommand test (PR #93122)

2024-05-22 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

The TestBreakpointCommand test is incorrectly disabled for Windows target. We 
can disable it for Windows host instead or just fix the issue. This patch fixes 
the path separator in BreakpointResolverFileLine::DeduceSourceMapping() and the 
Windows specific absolute path in the test in case of the Windows host.

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


2 Files Affected:

- (modified) lldb/source/Breakpoint/BreakpointResolverFileLine.cpp (+5-5) 
- (modified) 
lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
 (+13-5) 


``diff
diff --git a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp 
b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
index d7d8c714867e3..16c4ee1b88d16 100644
--- a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
+++ b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp
@@ -198,16 +198,16 @@ void BreakpointResolverFileLine::DeduceSourceMapping(
 return;
 
   Log *log = GetLog(LLDBLog::Breakpoints);
-  const llvm::StringRef path_separator = llvm::sys::path::get_separator(
-  m_location_spec.GetFileSpec().GetPathStyle());
   // Check if "b" is a suffix of "a".
   // And return std::nullopt if not or the new path
   // of "a" after consuming "b" from the back.
   auto check_suffix =
-  [path_separator](llvm::StringRef a, llvm::StringRef b,
-   bool case_sensitive) -> std::optional {
+  [](llvm::StringRef a, llvm::StringRef b,
+ bool case_sensitive) -> std::optional {
 if (case_sensitive ? a.consume_back(b) : a.consume_back_insensitive(b)) {
-  if (a.empty() || a.ends_with(path_separator)) {
+  // Note sc_file_dir and request_file_dir below are normalized
+  // and always contain the path separator '/'.
+  if (a.empty() || a.ends_with("/")) {
 return a;
   }
 }
diff --git 
a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
 
b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
index c219a4ee5bd9c..605561c757372 100644
--- 
a/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
+++ 
b/lldb/test/API/functionalities/breakpoint/breakpoint_command/TestBreakpointCommand.py
@@ -6,7 +6,7 @@
 import lldb
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
+from lldbsuite.test import lldbutil, lldbplatformutil
 import json
 import os
 import side_effect
@@ -581,7 +581,6 @@ def verify_source_map_deduce_statistics(self, target, 
expected_count):
 self.assertNotEqual(target_stats, None)
 self.assertEqual(target_stats["sourceMapDeduceCount"], expected_count)
 
-@skipIf(oslist=["windows"])
 @no_debug_info_test
 def test_breakpoints_auto_source_map_relative(self):
 """
@@ -612,8 +611,13 @@ def test_breakpoints_auto_source_map_relative(self):
 self.verify_source_map_deduce_statistics(target, 0)
 
 # Verify auto deduced source map when file path in debug info
-# is a suffix of request breakpoint file path
-path = "/x/y/a/b/c/main.cpp"
+# is a suffix of request breakpoint file path.
+# Note the path must be absolute.
+path = (
+"/x/y/a/b/c/main.cpp"
+if lldbplatformutil.getHostPlatform() != "windows"
+else r"C:\x\y\a\b\c\main.cpp"
+)
 bp = target.BreakpointCreateByLocation(path, 2)
 self.assertGreater(
 bp.GetNumLocations(),
@@ -625,7 +629,11 @@ def test_breakpoints_auto_source_map_relative(self):
 
 source_map_json = self.get_source_map_json()
 self.assertEqual(len(source_map_json), 1, "source map should not be 
empty")
-self.verify_source_map_entry_pair(source_map_json[0], ".", "/x/y")
+self.verify_source_map_entry_pair(
+source_map_json[0],
+".",
+"/x/y" if lldbplatformutil.getHostPlatform() != "windows" else 
r"C:\x\y",
+)
 self.verify_source_map_deduce_statistics(target, 1)
 
 # Reset source map.

``




https://github.com/llvm/llvm-project/pull/93122
___
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-22 Thread Aaron Siddhartha Mondal via lldb-commits

https://github.com/aaronmondal updated 
https://github.com/llvm/llvm-project/pull/92865

>From 124be680ca3ae82edd6fa9a49b1fd171d1babbf5 Mon Sep 17 00:00:00 2001
From: Aaron Siddhartha Mondal 
Date: Tue, 21 May 2024 06:37:49 +0200
Subject: [PATCH] [Support] Remove terminfo dependency

The terminfo dependency introduces a significant nonhermeticity into the
build. It doesn't respect `--no-undefined-version` meaning that it's not
a dependency that can be built with Clang 17+. This forces maintainers
of source-based distributions to implement patches or ignore linker
errors.

Remove it to reduce the closure size and improve portability of
LLVM-based tools. Users can still use command line arguments to toggle
color support expliticly.

Fixes #75490
Closes #53294 #23355
---
 clang/cmake/caches/Fuchsia-stage2.cmake   |  1 -
 clang/cmake/caches/Fuchsia.cmake  |  7 ---
 clang/cmake/caches/VectorEngine.cmake |  4 +-
 clang/utils/analyzer/entrypoint.py|  2 +-
 compiler-rt/cmake/config-ix.cmake | 15 -
 .../symbolizer/scripts/build_symbolizer.sh|  1 -
 compiler-rt/lib/xray/tests/CMakeLists.txt |  5 --
 lldb/docs/resources/build.rst |  1 -
 lldb/source/Core/CMakeLists.txt   |  3 -
 llvm/CMakeLists.txt   |  2 -
 llvm/cmake/config-ix.cmake| 10 
 llvm/cmake/modules/FindTerminfo.cmake | 55 -
 llvm/cmake/modules/LLVMConfig.cmake.in|  5 --
 llvm/docs/ReleaseNotes.rst|  4 ++
 llvm/include/llvm/Config/config.h.cmake   |  3 -
 llvm/lib/Support/CMakeLists.txt   | 11 
 llvm/lib/Support/Unix/Process.inc | 60 ++-
 llvm/utils/gn/README.rst  |  2 +-
 llvm/utils/gn/build/libs/terminfo/BUILD.gn| 12 
 llvm/utils/gn/build/libs/terminfo/enable.gni  |  4 --
 .../llvm/include/llvm/Config/BUILD.gn |  7 ---
 .../gn/secondary/llvm/lib/Support/BUILD.gn|  1 -
 .../secondary/llvm/tools/llvm-config/BUILD.gn |  6 +-
 utils/bazel/.bazelrc  |  3 -
 .../llvm/include/llvm/Config/config.h |  3 -
 utils/bazel/llvm_configs/config.h.cmake   |  3 -
 26 files changed, 12 insertions(+), 218 deletions(-)
 delete mode 100644 llvm/cmake/modules/FindTerminfo.cmake
 delete mode 100644 llvm/utils/gn/build/libs/terminfo/BUILD.gn
 delete mode 100644 llvm/utils/gn/build/libs/terminfo/enable.gni

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index d5546e20873b3..66e764968e85c 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -19,7 +19,6 @@ set(LLVM_ENABLE_LLD ON CACHE BOOL "")
 set(LLVM_ENABLE_LTO ON CACHE BOOL "")
 set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
 set(LLVM_ENABLE_PLUGINS OFF CACHE BOOL "")
-set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
 set(LLVM_ENABLE_UNWIND_TABLES OFF CACHE BOOL "")
 set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
diff --git a/clang/cmake/caches/Fuchsia.cmake b/clang/cmake/caches/Fuchsia.cmake
index 30a3b9116a461..4d3af3ad3f403 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -12,7 +12,6 @@ set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "")
 set(LLVM_ENABLE_LIBEDIT OFF CACHE BOOL "")
 set(LLVM_ENABLE_LIBXML2 OFF CACHE BOOL "")
 set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
-set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
 set(LLVM_ENABLE_UNWIND_TABLES OFF CACHE BOOL "")
 set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")
 set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
@@ -34,7 +33,6 @@ set(_FUCHSIA_BOOTSTRAP_PASSTHROUGH
   LibXml2_ROOT
   LLVM_ENABLE_CURL
   LLVM_ENABLE_HTTPLIB
-  LLVM_ENABLE_TERMINFO
   LLVM_ENABLE_LIBEDIT
   CURL_ROOT
   OpenSSL_ROOT
@@ -47,11 +45,6 @@ set(_FUCHSIA_BOOTSTRAP_PASSTHROUGH
   CURSES_LIBRARIES
   PANEL_LIBRARIES
 
-  # Deprecated
-  Terminfo_ROOT
-
-  Terminfo_LIBRARIES
-
   # Deprecated
   LibEdit_ROOT
 
diff --git a/clang/cmake/caches/VectorEngine.cmake 
b/clang/cmake/caches/VectorEngine.cmake
index 2f968a21cc407..b429fb0997d7a 100644
--- a/clang/cmake/caches/VectorEngine.cmake
+++ b/clang/cmake/caches/VectorEngine.cmake
@@ -13,9 +13,7 @@
 #   ninja
 #
 
-# Disable TERMINFO, ZLIB, and ZSTD for VE since there is no pre-compiled
-# libraries.
-set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
+# Disable ZLIB, and ZSTD for VE since there is no pre-compiled libraries.
 set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "")
 set(LLVM_ENABLE_ZSTD OFF CACHE BOOL "")
 
diff --git a/clang/utils/analyzer/entrypoint.py 
b/clang/utils/analyzer/entrypoint.py
index ff877060bad69..4deb42db0a0b1 100644
--- a/clang/utils/analyzer/entrypoint.py
+++ b/clang/utils/analyzer/entrypoint.py
@@ -54,7 +54,7 @@ def is_cmake_needed():
 "cmake -G Ninja -DCMAKE_BUILD_TYPE=Release "
 "-DCMAKE_INSTALL_PREFIX=/analyzer -DLLVM_TARGETS_TO_BUILD=X86 "
 '-DLLVM_ENABLE_PRO

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

2024-05-22 Thread Fangrui Song via lldb-commits

https://github.com/MaskRay approved this pull request.


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