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

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

https://github.com/labath closed 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] 3e023d8 - [lldb] Remove DWARFDebugInfo DIERef footguns (#92894)

2024-05-29 Thread via lldb-commits

Author: Pavel Labath
Date: 2024-05-30T07:48:59+02:00
New Revision: 3e023d87d8e9a7bcf0a2feb2cee9b9ca47643a7e

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

LOG: [lldb] Remove DWARFDebugInfo DIERef footguns (#92894)

DWARFDebugInfo doesn't know how to resolve the "file_index" component of
a DIERef. This patch removes GetUnit (in favor of existing
GetUnitContainingDIEOffset) and changes GetDIE to take only the
components it actually uses.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index d28da728728e5..c37cc91e08ed1 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -222,10 +222,6 @@ DWARFUnit *DWARFDebugInfo::GetUnitAtOffset(DIERef::Section 
section,
   return result;
 }
 
-DWARFUnit *DWARFDebugInfo::GetUnit(const DIERef _ref) {
-  return GetUnitContainingDIEOffset(die_ref.section(), die_ref.die_offset());
-}
-
 DWARFUnit *
 DWARFDebugInfo::GetUnitContainingDIEOffset(DIERef::Section section,
dw_offset_t die_offset) {
@@ -253,9 +249,8 @@ bool DWARFDebugInfo::ContainsTypeUnits() {
 //
 // Get the DIE (Debug Information Entry) with the specified offset.
 DWARFDIE
-DWARFDebugInfo::GetDIE(const DIERef _ref) {
-  DWARFUnit *cu = GetUnit(die_ref);
-  if (cu)
-return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset());
+DWARFDebugInfo::GetDIE(DIERef::Section section, dw_offset_t die_offset) {
+  if (DWARFUnit *cu = GetUnitContainingDIEOffset(section, die_offset))
+return cu->GetNonSkeletonUnit().GetDIE(die_offset);
   return DWARFDIE(); // Not found
 }

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
index 456ebd908ccb2..4706b55d38ea9 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -38,11 +38,10 @@ class DWARFDebugInfo {
  uint32_t *idx_ptr = nullptr);
   DWARFUnit *GetUnitContainingDIEOffset(DIERef::Section section,
 dw_offset_t die_offset);
-  DWARFUnit *GetUnit(const DIERef _ref);
   DWARFUnit *GetSkeletonUnit(DWARFUnit *dwo_unit);
   DWARFTypeUnit *GetTypeUnitForHash(uint64_t hash);
   bool ContainsTypeUnits();
-  DWARFDIE GetDIE(const DIERef _ref);
+  DWARFDIE GetDIE(DIERef::Section section, dw_offset_t die_offset);
 
   enum {
 eDumpFlag_Verbose = (1 << 0),  // Verbose dumping

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index bc489e5b8ad46..661e4a78a0215 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1761,7 +1761,8 @@ SymbolFileDWARF::GetDIE(const DIERef _ref) {
 if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile()) {
   symbol_file = debug_map->GetSymbolFileByOSOIndex(*file_index); // OSO 
case
   if (symbol_file)
-return symbol_file->DebugInfo().GetDIE(die_ref);
+return symbol_file->DebugInfo().GetDIE(die_ref.section(),
+   die_ref.die_offset());
   return DWARFDIE();
 }
 
@@ -1778,7 +1779,7 @@ SymbolFileDWARF::GetDIE(const DIERef _ref) {
   if (symbol_file)
 return symbol_file->GetDIE(die_ref);
 
-  return DebugInfo().GetDIE(die_ref);
+  return DebugInfo().GetDIE(die_ref.section(), die_ref.die_offset());
 }
 
 /// Return the DW_AT_(GNU_)dwo_id.
@@ -3786,7 +3787,7 @@ SymbolFileDWARF::FindBlockContainingSpecification(
   // Give the concrete function die specified by "func_die_offset", find the
   // concrete block whose DW_AT_specification or DW_AT_abstract_origin points
   // to "spec_block_die_offset"
-  return FindBlockContainingSpecification(DebugInfo().GetDIE(func_die_ref),
+  return FindBlockContainingSpecification(GetDIE(func_die_ref),
   spec_block_die_offset);
 }
 

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
index 8fd369c65f86b..e4db39cabf6fe 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -145,7 +145,7 @@ SymbolFileDWARFDwo::GetTypeSystemForLanguage(LanguageType 

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

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

clayborg wrote:

So I am trying to lookup `std::ios_base` in my example for a real definitions, 
but I end up with thousands of forward declarations due to the DWARF snippet in 
my original summary string. 

So when I lookup `std::ios_base`, I found thousands of `DW_AT_declaration` 
entries for `std::ios_base` that I don't want to propagate beyond the DWARF 
index class handing out valid matches, so thus this patch. There _are_ entries 
in the name tables for `std::ios_base` that are declarations only and it would 
be great if these are not here, but someone is producing them somehow, I am not 
sure if this is clang or bolt.

The way I saw this was to enable DWARF logging in LLDB and if I did that I saw 
thousands of `ios_base` lookups that failed to produce real types and this was 
why I created this patch.

Thanks for the detailed explanations above everyone.

I would vote to get this in to reduce churn when doing type lookups, even if we 
do fix the compiler, linker, and or other tools to not produce them in the 
future, we still have such binaries floating around from past compilers, 
linkers and other tools. 

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] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

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

ayermolo wrote:

I have another question. 
For the same example.
I see:

```
Name 4 {
  Hash: 0x2F94396D
  String: 0x0049 "_Z9get_statev"
  Entry @ 0x112 {
Abbrev: 0x2
Tag: DW_TAG_subprogram
DW_IDX_die_offset: 0x0023
DW_IDX_parent: 
  }
...  
Name 8 {
  Hash: 0x2B607
  String: 0x0041 "B"
  Entry @ 0x13b {
Abbrev: 0x7
Tag: DW_TAG_namespace
DW_IDX_type_unit: 0x00
DW_IDX_die_offset: 0x0025
DW_IDX_parent: Entry @ 0x112
  }
```

This seems like a bug no?
Looks like it's confusing

```
0x0023:   DW_TAG_namespace
DW_AT_name  ("A")
```
In TU 0
With Subprogram at the same (relative offset) in the CU

```
0x006a: Compile Unit: length = 0x005c, format = DWARF32, version = 
0x0005, unit_type = DW_UT_compile, abbr_offset = 0x, addr_size = 0x08 (next 
unit at 0x00ca)
...
0x008d:   DW_TAG_subprogram
```

I think it should be pointing to:

```
String: 0x0023 "A"
  Entry @ 0x11e {
Abbrev: 0x4
Tag: DW_TAG_namespace
DW_IDX_type_unit: 0x00
DW_IDX_die_offset: 0x0023
DW_IDX_parent: 
  }
```




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] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

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

https://github.com/clayborg updated 
https://github.com/llvm/llvm-project/pull/91808

>From 0cc1be6988e6ab5498151f32485f525a66133be2 Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Fri, 10 May 2024 13:49:22 -0700
Subject: [PATCH 1/2] Improve performance of .debug_names lookups when
 DW_IDX_parent attributes are used.

When a .debug_names table has entries that use the DW_IDX_parent attributes, we 
can end up with entries in the .debug_names table that are not full 
definitions. This is because a class that is foward declared, can contain 
types. For example:

0x0090cdbf: DW_TAG_compile_unit
  DW_AT_producer("clang version 15.0.7")
  DW_AT_language(DW_LANG_C_plus_plus_14)
  DW_AT_name("UniqueInstance.cpp")

0x0090cdc7:   DW_TAG_namespace
DW_AT_name  ("std")

0x0090cdd5: DW_TAG_class_type
  DW_AT_name("ios_base")
  DW_AT_declaration (true)

0x0090cdd7:   DW_TAG_class_type
DW_AT_name  ("Init")
DW_AT_declaration   (true)

0x0090cdda:   DW_TAG_typedef
DW_AT_type  (0x0090ce4e "std::_Ios_Seekdir")
DW_AT_name  ("seekdir")
DW_AT_decl_file (0x11)
DW_AT_decl_line (479)

0x0090cde4:   DW_TAG_typedef
DW_AT_type  (0x0090ce45 "std::_Ios_Openmode")
DW_AT_name  ("openmode")
DW_AT_decl_file (0x11)
DW_AT_decl_line (447)

0x0090cdee:   DW_TAG_typedef
DW_AT_type  (0x0090ce3c "std::_Ios_Iostate")
DW_AT_name  ("iostate")
DW_AT_decl_file (0x11)
DW_AT_decl_line (416)

0x0090cdf8:   NULL

"std::ios_base" is forward declared and it contains typedefs whose entries in 
the .debug_names table will point to the DIE at offset 0x0090cdd5. These 
entries cause our type lookups to try and parse a TON of forward declarations 
and waste time and resources.

This fix makes sure when/if we find an entry in the .debug_names table, we 
don't process it if it has a DW_AT_declaration(true) attribute.
---
 lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 4 
 1 file changed, 4 insertions(+)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 4da0d56fdcacb..eaa9f591ffd41 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -83,6 +83,10 @@ bool DebugNamesDWARFIndex::ProcessEntry(
   DWARFDIE die = dwarf.GetDIE(*ref);
   if (!die)
 return true;
+  // Watch out for forward declarations that appear in the .debug_names tables
+  // only due to being there for a DW_IDX_parent.
+  if (die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0))
+return true;
   return callback(die);
 }
 

>From 8faad14da0aac8d207db29893c5e089a6151 Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Wed, 29 May 2024 15:39:02 -0700
Subject: [PATCH 2/2] Fix comment as suggested.

---
 lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index eaa9f591ffd41..0c7170c0025e0 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -83,8 +83,8 @@ bool DebugNamesDWARFIndex::ProcessEntry(
   DWARFDIE die = dwarf.GetDIE(*ref);
   if (!die)
 return true;
-  // Watch out for forward declarations that appear in the .debug_names tables
-  // only due to being there for a DW_IDX_parent.
+  // Clang erroneously emits index entries for declaration DIEs in case when 
the
+  // definition is in a type unit (llvm.org/pr77696). Weed those out.
   if (die.GetAttributeValueAsUnsigned(DW_AT_declaration, 0))
 return true;
   return callback(die);

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


[Lldb-commits] [lldb] [lldb] Use packaging module instead of pkg_resources (PR #93712)

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

JDevlieghere wrote:

> At least at present, this will probably break Fuchsia's build; the Python we 
> ship includes `pkg_resources` but not `packaging`. Is the default `cpython` 
> build from source intended to build and install `packaging`? Is this 
> something that changed recently?

I'm not sure but I don't think so. IIUC the expectation that if folks want to 
use the packaging module, they have to install it themselves (i.e. with pip). 
I'm not sure all the bots have this package which is the reason I went with the 
`pkg_resources` approach previously, but that no longer works (i.e. Python 3.12 
installed via homebrew no longer has it which is why we've seen folks hitting 
this). 

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


[Lldb-commits] [lldb] Reapply [lldb][DWARF] Delay struct/class/union definition DIE searching when parsing declaration DIEs. (PR #92328)

2024-05-29 Thread Michael Buch via lldb-commits

Michael137 wrote:

Unfortunately this breaks `TestCPPAccelerator.py` on the macOS buildbots: 
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/4788/execution/node/97/log/

```
Ran command:
"log enable dwarf lookups 
-f/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/lldb-test-build.noindex/lang/cpp/accelerator-table/TestCPPAccelerator.test_dwarf/dwarf.log"

Got output:


runCmd: frame variable inner_d

Assertion failed: (DD && "queried property of class with no definition"), 
function data, file DeclCXX.h, line 464.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace.
Stack dump:
0.  HandleCommand(command = "frame variable inner_d")
```

The stacktrace I got when locally reproducing this:
```
Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib 0x18e0a1540 __pthread_kill + 8
1   libsystem_pthread.dylib0x18e0d9bcc pthread_kill + 288
2   libsystem_c.dylib  0x18dfe6964 __abort + 136
3   libsystem_c.dylib  0x18dfe68dc abort + 140
4   libsystem_c.dylib  0x18dfe5bc8 __assert_rtn + 284
5   liblldb.19.0.0git.dylib0x31fd217c0 
clang::CXXRecordDecl::data() const + 112
6   liblldb.19.0.0git.dylib0x31fe9cb8c 
clang::CXXRecordDecl::hasUserDeclaredMoveConstructor() const + 24
7   liblldb.19.0.0git.dylib0x31fe7edf8 
lldb_private::TypeSystemClang::CompleteTagDeclarationDefinition(lldb_private::CompilerType
 const&) + 256
8   liblldb.19.0.0git.dylib0x31fd142a8 
DWARFASTParserClang::CompleteRecordType(lldb_private::plugin::dwarf::DWARFDIE 
const&, lldb_private::Type*, lldb_private::CompilerType&) + 1024
9   liblldb.19.0.0git.dylib0x31fd14f4c 
DWARFASTParserClang::CompleteTypeFromDWARF(lldb_private::plugin::dwarf::DWARFDIE
 const&, lldb_private::Type*, lldb_private::CompilerType&) + 316
10  liblldb.19.0.0git.dylib0x31fd9cc78 
lldb_private::plugin::dwarf::SymbolFileDWARF::CompleteType(lldb_private::CompilerType&)
 + 1160
11  liblldb.19.0.0git.dylib0x31fdf3a64 
lldb_private::plugin::dwarf::SymbolFileDWARFDebugMap::CompleteType(lldb_private::CompilerType&)::$_0::operator()(lldb_private::plugin::dwarf::SymbolFileDWARF*)
 const + 72
12  liblldb.19.0.0git.dylib0x31fdf3a10 
decltype(std::declval()(std::declval()))
 
std::__1::__invoke[abi:nn180100](lldb_private::plugin::dwarf::SymbolFileDWARFDebugMap::CompleteType(lldb_private::CompilerType&)::$_0&,
 lldb_private::plugin::dwarf::SymbolFileDWARF*&&) + 36
13  liblldb.19.0.0git.dylib0x31fdf39bc 
lldb_private::IterationAction 
std::__1::__invoke_void_return_wrapper::__call[abi:nn180100](lldb_private::plugin::dwarf::SymbolFileDWARFDebugMap::CompleteType(lldb_private::CompilerType&)::$_0&,
 lldb_private::plugin::dwarf::SymbolFileDWARF*&&) + 32
14  liblldb.19.0.0git.dylib0x31fdf3990 
std::__1::__function::__alloc_func,
 lldb_private::IterationAction 
(lldb_private::plugin::dwarf::SymbolFileDWARF*)>::operator()[abi:nn180100](lldb_private::plugin::dwarf::SymbolFileDWARF*&&)
 + 36
15  liblldb.19.0.0git.dylib0x31fdf28a4 
std::__1::__function::__func,
 lldb_private::IterationAction 
(lldb_private::plugin::dwarf::SymbolFileDWARF*)>::operator()(lldb_private::plugin::dwarf::SymbolFileDWARF*&&)
 + 36
16  liblldb.19.0.0git.dylib0x31fde1f84 
std::__1::__function::__value_func::operator()[abi:nn180100](lldb_private::plugin::dwarf::SymbolFileDWARF*&&)
 const + 76
17  liblldb.19.0.0git.dylib0x31fde1f2c 
std::__1::function::operator()(lldb_private::plugin::dwarf::SymbolFileDWARF*)
 const + 36
18  liblldb.19.0.0git.dylib0x31fdde658 
lldb_private::plugin::dwarf::SymbolFileDWARFDebugMap::ForEachSymbolFile(std::__1::function) + 128
19  liblldb.19.0.0git.dylib0x31fdde58c 
lldb_private::plugin::dwarf::SymbolFileDWARFDebugMap::CompleteType(lldb_private::CompilerType&)
 + 112
20  liblldb.19.0.0git.dylib0x31fe9f5cc 
lldb_private::TypeSystemClang::CompleteTagDecl(clang::TagDecl*) + 120
21  liblldb.19.0.0git.dylib0x321364718 
lldb_private::ClangExternalASTSourceCallbacks::CompleteType(clang::TagDecl*) + 
36
22  liblldb.19.0.0git.dylib0x31fe82b94 
GetCompleteQualType(clang::ASTContext*, clang::QualType, bool) + 516
23  liblldb.19.0.0git.dylib0x31fe8e1f4 
lldb_private::TypeSystemClang::GetNumChildren(void*, bool, 
lldb_private::ExecutionContext const*) + 436
24  liblldb.19.0.0git.dylib0x31f2f7f88 
lldb_private::CompilerType::GetNumChildren(bool, lldb_private::ExecutionContext 
const*) const + 144
25  liblldb.19.0.0git.dylib0x31fe8e60c 

[Lldb-commits] [lldb] [lldb] Remove setupterm workaround on macOS (PR #93714)

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

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


[Lldb-commits] [lldb] c6c08ee - [lldb] Remove setupterm workaround on macOS (#93714)

2024-05-29 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-05-29T14:21:06-07:00
New Revision: c6c08eee37bada190bd1aa4593c88a5e2c8cdaac

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

LOG: [lldb] Remove setupterm workaround on macOS (#93714)

Remove setupterm workaround on macOS which caused an issues after the
removal of the terminfo dependency. There's a comment that explains why
the workaround is present, but neither Jim nor I were able to reproduce
the issue by setting TERM to vt100.

Added: 


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

Removed: 




diff  --git a/lldb/source/Host/common/Editline.cpp 
b/lldb/source/Host/common/Editline.cpp
index ed61aecc23b9b..561ec228cdb23 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -31,20 +31,6 @@
 using namespace lldb_private;
 using namespace lldb_private::line_editor;
 
-// Workaround for what looks like an OS X-specific issue, but other platforms
-// may benefit from something similar if issues arise.  The libedit library
-// doesn't explicitly initialize the curses termcap library, which it gets away
-// with until TERM is set to VT100 where it stumbles over an implementation
-// assumption that may not exist on other platforms.  The setupterm() function
-// would normally require headers that don't work gracefully in this context,
-// so the function declaration has been hoisted here.
-#if defined(__APPLE__)
-extern "C" {
-int setupterm(char *term, int fildes, int *errret);
-}
-#define USE_SETUPTERM_WORKAROUND
-#endif
-
 // Editline uses careful cursor management to achieve the illusion of editing a
 // multi-line block of text with a single line editor.  Preserving this
 // illusion requires fairly careful management of cursor state.  Read and
@@ -1402,35 +1388,6 @@ Editline::Editline(const char *editline_name, FILE 
*input_file,
   // Get a shared history instance
   m_editor_name = (editline_name == nullptr) ? "lldb-tmp" : editline_name;
   m_history_sp = EditlineHistory::GetHistory(m_editor_name);
-
-#ifdef USE_SETUPTERM_WORKAROUND
-  if (m_output_file) {
-const int term_fd = fileno(m_output_file);
-if (term_fd != -1) {
-  static std::recursive_mutex *g_init_terminal_fds_mutex_ptr = nullptr;
-  static std::set *g_init_terminal_fds_ptr = nullptr;
-  static llvm::once_flag g_once_flag;
-  llvm::call_once(g_once_flag, [&]() {
-g_init_terminal_fds_mutex_ptr =
-new std::recursive_mutex(); // NOTE: Leak to avoid C++ destructor
-// chain issues
-g_init_terminal_fds_ptr = new std::set(); // NOTE: Leak to avoid
-   // C++ destructor chain
-   // issues
-  });
-
-  // We must make sure to initialize the terminal a given file descriptor
-  // only once. If we do this multiple times, we start leaking memory.
-  std::lock_guard guard(
-  *g_init_terminal_fds_mutex_ptr);
-  if (g_init_terminal_fds_ptr->find(term_fd) ==
-  g_init_terminal_fds_ptr->end()) {
-g_init_terminal_fds_ptr->insert(term_fd);
-setupterm((char *)0, term_fd, (int *)0);
-  }
-}
-  }
-#endif
 }
 
 Editline::~Editline() {



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


[Lldb-commits] [lldb] Revert "[lldb][lldb-dap] Cleanup breakpoint filters." (PR #93739)

2024-05-29 Thread via lldb-commits

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


[Lldb-commits] [lldb] 6595e7f - Revert "[lldb][lldb-dap] Cleanup breakpoint filters." (#93739)

2024-05-29 Thread via lldb-commits

Author: gulfemsavrun
Date: 2024-05-29T13:56:37-07:00
New Revision: 6595e7fa1b5588f860aa057aac47c43623169584

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

LOG: Revert "[lldb][lldb-dap] Cleanup breakpoint filters." (#93739)

Reverts llvm/llvm-project#87550 because it broke `TestDAP*` lldb tests.

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

Added: 


Modified: 
lldb/include/lldb/API/SBDebugger.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/API/SBDebugger.cpp
lldb/source/Symbol/TypeSystem.cpp
lldb/tools/lldb-dap/DAP.cpp
lldb/tools/lldb-dap/DAP.h
lldb/tools/lldb-dap/lldb-dap.cpp

Removed: 




diff  --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 84ea9c0f772e1..af19b1faf3bf5 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,8 +57,6 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
-  static bool SupportsLanguage(lldb::LanguageType language);
-
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.

diff  --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index 7d48f9b316138..b4025c173a186 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,7 +209,6 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
-  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;

diff  --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 29da7d33dd80b..7ef0d6efd4aaa 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,7 +1742,3 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
-
-bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
-  return TypeSystem::SupportsLanguageStatic(language);
-}

diff  --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 5d56d9b1829da..4956f10a0b0a7 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,14 +335,3 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
-
-bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
-  if (language == eLanguageTypeUnknown)
-return false;
-
-  LanguageSet languages =
-  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
-  if (languages.Empty())
-return false;
-  return languages[language];
-}

diff  --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 807d27c2c869d..d419f821999e6 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,7 +32,14 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"), exception_breakpoints(),
+: broadcaster("lldb-dap"),
+  exception_breakpoints(
+  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
+   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
+   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
+   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
+   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
+   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -58,32 +65,8 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
-void DAP::PopulateExceptionBreakpoints() {
-  exception_breakpoints = {};
-  if (debugger.SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
-exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
-lldb::eLanguageTypeC_plus_plus);
-exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
-lldb::eLanguageTypeC_plus_plus);
-  }
-  if (debugger.SupportsLanguage(lldb::eLanguageTypeObjC)) {
-exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
-lldb::eLanguageTypeObjC);
-exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
-lldb::eLanguageTypeObjC);
-  }
-  if (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) {
-

[Lldb-commits] [lldb] Revert "[lldb][lldb-dap] Cleanup breakpoint filters." (PR #93739)

2024-05-29 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (gulfemsavrun)


Changes

Reverts llvm/llvm-project#87550 because it broke `TestDAP*` lldb tests.
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64-rbe/b8746585790559468897/overview

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


7 Files Affected:

- (modified) lldb/include/lldb/API/SBDebugger.h (-2) 
- (modified) lldb/include/lldb/Symbol/TypeSystem.h (-1) 
- (modified) lldb/source/API/SBDebugger.cpp (-4) 
- (modified) lldb/source/Symbol/TypeSystem.cpp (-11) 
- (modified) lldb/tools/lldb-dap/DAP.cpp (+10-29) 
- (modified) lldb/tools/lldb-dap/DAP.h (+1-3) 
- (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+2-4) 


``diff
diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 84ea9c0f772e1..af19b1faf3bf5 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,8 +57,6 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
-  static bool SupportsLanguage(lldb::LanguageType language);
-
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index 7d48f9b316138..b4025c173a186 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,7 +209,6 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
-  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 29da7d33dd80b..7ef0d6efd4aaa 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,7 +1742,3 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
-
-bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
-  return TypeSystem::SupportsLanguageStatic(language);
-}
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 5d56d9b1829da..4956f10a0b0a7 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,14 +335,3 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
-
-bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
-  if (language == eLanguageTypeUnknown)
-return false;
-
-  LanguageSet languages =
-  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
-  if (languages.Empty())
-return false;
-  return languages[language];
-}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 807d27c2c869d..d419f821999e6 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,7 +32,14 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"), exception_breakpoints(),
+: broadcaster("lldb-dap"),
+  exception_breakpoints(
+  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
+   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
+   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
+   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
+   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
+   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -58,32 +65,8 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
-void DAP::PopulateExceptionBreakpoints() {
-  exception_breakpoints = {};
-  if (debugger.SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
-exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
-lldb::eLanguageTypeC_plus_plus);
-exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
-lldb::eLanguageTypeC_plus_plus);
-  }
-  if (debugger.SupportsLanguage(lldb::eLanguageTypeObjC)) {
-exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
-lldb::eLanguageTypeObjC);
-exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
-lldb::eLanguageTypeObjC);
-  }
-  if (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) {
-exception_breakpoints->emplace_back("swift_catch", "Swift Catch",
-lldb::eLanguageTypeSwift);
-exception_breakpoints->emplace_back("swift_throw", 

[Lldb-commits] [lldb] Revert "[lldb][lldb-dap] Cleanup breakpoint filters." (PR #93739)

2024-05-29 Thread via lldb-commits

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


[Lldb-commits] [lldb] Revert "[lldb][lldb-dap] Cleanup breakpoint filters." (PR #93739)

2024-05-29 Thread via lldb-commits

https://github.com/gulfemsavrun created 
https://github.com/llvm/llvm-project/pull/93739

Reverts llvm/llvm-project#87550 because it broke `TestDAP*` lldb tests.

>From 9f72683d223dd8b05ba5efc7590fbb9c725d55c1 Mon Sep 17 00:00:00 2001
From: gulfemsavrun 
Date: Wed, 29 May 2024 13:44:48 -0700
Subject: [PATCH] Revert "[lldb][lldb-dap] Cleanup breakpoint filters.
 (#87550)"

This reverts commit cfb209b92a26f16ed7413b32da20fc436eff8c58.
---
 lldb/include/lldb/API/SBDebugger.h|  2 --
 lldb/include/lldb/Symbol/TypeSystem.h |  1 -
 lldb/source/API/SBDebugger.cpp|  4 ---
 lldb/source/Symbol/TypeSystem.cpp | 11 
 lldb/tools/lldb-dap/DAP.cpp   | 39 +++
 lldb/tools/lldb-dap/DAP.h |  4 +--
 lldb/tools/lldb-dap/lldb-dap.cpp  |  6 ++---
 7 files changed, 13 insertions(+), 54 deletions(-)

diff --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index 84ea9c0f772e1..af19b1faf3bf5 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,8 +57,6 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
-  static bool SupportsLanguage(lldb::LanguageType language);
-
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index 7d48f9b316138..b4025c173a186 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,7 +209,6 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
-  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 29da7d33dd80b..7ef0d6efd4aaa 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,7 +1742,3 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
-
-bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
-  return TypeSystem::SupportsLanguageStatic(language);
-}
diff --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 5d56d9b1829da..4956f10a0b0a7 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,14 +335,3 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
-
-bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
-  if (language == eLanguageTypeUnknown)
-return false;
-
-  LanguageSet languages =
-  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
-  if (languages.Empty())
-return false;
-  return languages[language];
-}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 807d27c2c869d..d419f821999e6 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,7 +32,14 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"), exception_breakpoints(),
+: broadcaster("lldb-dap"),
+  exception_breakpoints(
+  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
+   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
+   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
+   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
+   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
+   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -58,32 +65,8 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
-void DAP::PopulateExceptionBreakpoints() {
-  exception_breakpoints = {};
-  if (debugger.SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
-exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
-lldb::eLanguageTypeC_plus_plus);
-exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
-lldb::eLanguageTypeC_plus_plus);
-  }
-  if (debugger.SupportsLanguage(lldb::eLanguageTypeObjC)) {
-exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
-lldb::eLanguageTypeObjC);
-exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
-lldb::eLanguageTypeObjC);
-  }
-  if (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) {
-exception_breakpoints->emplace_back("swift_catch", "Swift Catch",
- 

[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-29 Thread via lldb-commits

gulfemsavrun wrote:

We started seeing lldb test failures in `TestDAP*`.
```
==
FAIL: test_commands (TestDAP_launch.TestDAP_launch.test_commands)
Tests the "initCommands", "preRunCommands", "stopCommands",
--
Traceback (most recent call last):
  File 
"/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py",
 line 150, in wrapper
return func(*args, **kwargs)
   ^
  File 
"/b/s/w/ir/x/w/llvm-llvm-project/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py",
 line 324, in test_commands
self.continue_to_breakpoints(breakpoint_ids)
  File 
"/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py",
 line 245, in continue_to_breakpoints
self.verify_breakpoint_hit(breakpoint_ids)
  File 
"/b/s/w/ir/x/w/llvm-llvm-project/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py",
 line 99, in verify_breakpoint_hit
self.assertTrue(False, "breakpoint not hit")
AssertionError: False is not true : breakpoint not hit
```

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


[Lldb-commits] [lldb] [lldb] Remove setupterm workaround on macOS (PR #93714)

2024-05-29 Thread via lldb-commits

jimingham wrote:

I tried running this lldb on a vt100 terminal, and ran lldb under lldb, but 
doing:

(top-lldb) env TERM=vt100
(top-lldb) run

in case it was switching the terminal that was causing the issue.

We don't work wonderfully in a vt100 terminal, for instance if you do:

```
(lldb) breakpoint command add
> bt
> list

```
on a vt100 terminal, that inserts the up arrow control character rather than 
going to the previous line. But the same thing happens with and without this 
workaround.

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


[Lldb-commits] [lldb] [lldb] Use packaging module instead of pkg_resources (PR #93712)

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

mysterymath wrote:

At least at present, this will probably break Fuchsia's build; the Python we 
ship includes `pkg_resources` but not `packaging`. Is the default `cpython` 
build from source intended to build and install `packaging`? Is this something 
that changed recently?

https://github.com/llvm/llvm-project/pull/93712
___
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-29 Thread Alexander Yermolovich via lldb-commits

ayermolo wrote:

> > I have a follow up question.
> 
> It sounds like you've answered it yourself. :)
> 
> With this kind of debug info, lldb would think this refers to a global entity 
> and return it for queries like `::InnerState`. Without that entry, lldb will 
> (correctly) look up the context in the DIE tree, and compare it that way.

Yes, although it wasn't clear to me how lldb would handle it. Thanks for 
elaborating. :)

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] Remove setupterm workaround on macOS (PR #93714)

2024-05-29 Thread Med Ismail Bennani via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Use packaging module instead of pkg_resources (PR #93712)

2024-05-29 Thread Med Ismail Bennani via lldb-commits

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


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


[Lldb-commits] [clang] [lldb] [llvm] Revert "[IR] Update ptrauth const prop test to avoid constant icmp." (PR #93715)

2024-05-29 Thread Francis Visoiu Mistrih via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] Revert "[IR] Update ptrauth const prop test to avoid constant icmp." (PR #93715)

2024-05-29 Thread Francis Visoiu Mistrih via lldb-commits

https://github.com/francisvm created 
https://github.com/llvm/llvm-project/pull/93715

None

error: too big or took too long to generate
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Use packaging module instead of pkg_resources (PR #93712)

2024-05-29 Thread Jordan Rupprecht via lldb-commits

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

LGTM, but heads up for @mysterymath if this causes issues w/ Fuchsia's build

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


[Lldb-commits] [lldb] [lldb] Remove setupterm workaround on macOS (PR #93714)

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

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


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


[Lldb-commits] [lldb] [lldb] Remove setupterm workaround on macOS (PR #93714)

2024-05-29 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Remove setupterm workaround on macOS which caused an issues after the removal 
of the terminfo dependency. There's a comment that explains why the workaround 
is present, but neither Jim nor I were able to reproduce the issue by setting 
TERM to vt100.

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


1 Files Affected:

- (modified) lldb/source/Host/common/Editline.cpp (-43) 


``diff
diff --git a/lldb/source/Host/common/Editline.cpp 
b/lldb/source/Host/common/Editline.cpp
index ed61aecc23b9b..561ec228cdb23 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -31,20 +31,6 @@
 using namespace lldb_private;
 using namespace lldb_private::line_editor;
 
-// Workaround for what looks like an OS X-specific issue, but other platforms
-// may benefit from something similar if issues arise.  The libedit library
-// doesn't explicitly initialize the curses termcap library, which it gets away
-// with until TERM is set to VT100 where it stumbles over an implementation
-// assumption that may not exist on other platforms.  The setupterm() function
-// would normally require headers that don't work gracefully in this context,
-// so the function declaration has been hoisted here.
-#if defined(__APPLE__)
-extern "C" {
-int setupterm(char *term, int fildes, int *errret);
-}
-#define USE_SETUPTERM_WORKAROUND
-#endif
-
 // Editline uses careful cursor management to achieve the illusion of editing a
 // multi-line block of text with a single line editor.  Preserving this
 // illusion requires fairly careful management of cursor state.  Read and
@@ -1402,35 +1388,6 @@ Editline::Editline(const char *editline_name, FILE 
*input_file,
   // Get a shared history instance
   m_editor_name = (editline_name == nullptr) ? "lldb-tmp" : editline_name;
   m_history_sp = EditlineHistory::GetHistory(m_editor_name);
-
-#ifdef USE_SETUPTERM_WORKAROUND
-  if (m_output_file) {
-const int term_fd = fileno(m_output_file);
-if (term_fd != -1) {
-  static std::recursive_mutex *g_init_terminal_fds_mutex_ptr = nullptr;
-  static std::set *g_init_terminal_fds_ptr = nullptr;
-  static llvm::once_flag g_once_flag;
-  llvm::call_once(g_once_flag, [&]() {
-g_init_terminal_fds_mutex_ptr =
-new std::recursive_mutex(); // NOTE: Leak to avoid C++ destructor
-// chain issues
-g_init_terminal_fds_ptr = new std::set(); // NOTE: Leak to avoid
-   // C++ destructor chain
-   // issues
-  });
-
-  // We must make sure to initialize the terminal a given file descriptor
-  // only once. If we do this multiple times, we start leaking memory.
-  std::lock_guard guard(
-  *g_init_terminal_fds_mutex_ptr);
-  if (g_init_terminal_fds_ptr->find(term_fd) ==
-  g_init_terminal_fds_ptr->end()) {
-g_init_terminal_fds_ptr->insert(term_fd);
-setupterm((char *)0, term_fd, (int *)0);
-  }
-}
-  }
-#endif
 }
 
 Editline::~Editline() {

``




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


[Lldb-commits] [lldb] [lldb] Remove setupterm workaround on macOS (PR #93714)

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

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/93714

Remove setupterm workaround on macOS which caused an issues after the removal 
of the terminfo dependency. There's a comment that explains why the workaround 
is present, but neither Jim nor I were able to reproduce the issue by setting 
TERM to vt100.

>From 030ab776933816a713a80852f0a32ff7d51ba8bd Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 29 May 2024 11:06:10 -0700
Subject: [PATCH] [lldb] Remove setupterm workaround on macOS

Remove setupterm workaround on macOS which caused an issues after the
removal of the terminfo dependency. There's a comment that explains why
the workaround is present, but neither Jim nor I were able to reproduce
the issue by setting TERM to vt100.
---
 lldb/source/Host/common/Editline.cpp | 43 
 1 file changed, 43 deletions(-)

diff --git a/lldb/source/Host/common/Editline.cpp 
b/lldb/source/Host/common/Editline.cpp
index ed61aecc23b9b..561ec228cdb23 100644
--- a/lldb/source/Host/common/Editline.cpp
+++ b/lldb/source/Host/common/Editline.cpp
@@ -31,20 +31,6 @@
 using namespace lldb_private;
 using namespace lldb_private::line_editor;
 
-// Workaround for what looks like an OS X-specific issue, but other platforms
-// may benefit from something similar if issues arise.  The libedit library
-// doesn't explicitly initialize the curses termcap library, which it gets away
-// with until TERM is set to VT100 where it stumbles over an implementation
-// assumption that may not exist on other platforms.  The setupterm() function
-// would normally require headers that don't work gracefully in this context,
-// so the function declaration has been hoisted here.
-#if defined(__APPLE__)
-extern "C" {
-int setupterm(char *term, int fildes, int *errret);
-}
-#define USE_SETUPTERM_WORKAROUND
-#endif
-
 // Editline uses careful cursor management to achieve the illusion of editing a
 // multi-line block of text with a single line editor.  Preserving this
 // illusion requires fairly careful management of cursor state.  Read and
@@ -1402,35 +1388,6 @@ Editline::Editline(const char *editline_name, FILE 
*input_file,
   // Get a shared history instance
   m_editor_name = (editline_name == nullptr) ? "lldb-tmp" : editline_name;
   m_history_sp = EditlineHistory::GetHistory(m_editor_name);
-
-#ifdef USE_SETUPTERM_WORKAROUND
-  if (m_output_file) {
-const int term_fd = fileno(m_output_file);
-if (term_fd != -1) {
-  static std::recursive_mutex *g_init_terminal_fds_mutex_ptr = nullptr;
-  static std::set *g_init_terminal_fds_ptr = nullptr;
-  static llvm::once_flag g_once_flag;
-  llvm::call_once(g_once_flag, [&]() {
-g_init_terminal_fds_mutex_ptr =
-new std::recursive_mutex(); // NOTE: Leak to avoid C++ destructor
-// chain issues
-g_init_terminal_fds_ptr = new std::set(); // NOTE: Leak to avoid
-   // C++ destructor chain
-   // issues
-  });
-
-  // We must make sure to initialize the terminal a given file descriptor
-  // only once. If we do this multiple times, we start leaking memory.
-  std::lock_guard guard(
-  *g_init_terminal_fds_mutex_ptr);
-  if (g_init_terminal_fds_ptr->find(term_fd) ==
-  g_init_terminal_fds_ptr->end()) {
-g_init_terminal_fds_ptr->insert(term_fd);
-setupterm((char *)0, term_fd, (int *)0);
-  }
-}
-  }
-#endif
 }
 
 Editline::~Editline() {

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


[Lldb-commits] [lldb] [lldb] Use packaging module instead of pkg_resources (PR #93712)

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

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


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


[Lldb-commits] [lldb] [lldb] Use packaging module instead of pkg_resources (PR #93712)

2024-05-29 Thread Augusto Noronha via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Use packaging module instead of pkg_resources (PR #93712)

2024-05-29 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Use the packaging [1] module for parsing version numbers, instead of 
pkg_resources which is distributed with setuptools. I recently switched over to 
using the latter, knowing it was deprecated (in favor of the packaging module) 
because it comes with Python out of the box. Newer versions of setuptools have 
removed `pkg_resources` so we have to use packaging.

[1] https://pypi.org/project/packaging/

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


4 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/decorators.py (+2-4) 
- (modified) lldb/packages/Python/lldbsuite/test/lldbplatformutil.py (+3-4) 
- (modified) lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py (+2-2) 
- (modified) lldb/test/Shell/helper/build.py (+2-2) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 79cc0a2aeacbe..4b85219ce7c19 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1,6 +1,6 @@
 # System modules
 from functools import wraps
-from pkg_resources import packaging
+from packaging.version import parse
 import ctypes
 import locale
 import os
@@ -66,9 +66,7 @@ def fn_neq(x, y):
 "<=": fn_leq,
 }
 
-return op_lookup[comparison](
-packaging.version.parse(actual), packaging.version.parse(expected)
-)
+return op_lookup[comparison](parse(actual), parse(expected))
 
 
 def _match_decorator_property(expected, actual):
diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 187d16aa1baa6..ecc814b016059 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -8,8 +8,7 @@
 import subprocess
 import sys
 import os
-from urllib.parse import urlparse
-from pkg_resources import packaging
+from packaging.version import parse
 
 # LLDB modules
 import lldb
@@ -309,8 +308,8 @@ def expectedCompilerVersion(compiler_version):
 # Assume the compiler version is at or near the top of trunk.
 return operator in [">", ">=", "!", "!=", "not"]
 
-version = packaging.version.parse(version_str)
-test_compiler_version = packaging.version.parse(test_compiler_version_str)
+version = parse(version_str)
+test_compiler_version = parse(test_compiler_version_str)
 
 if operator == ">":
 return test_compiler_version > version
diff --git a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py 
b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
index d770447f0771c..6dd838dab168b 100644
--- a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -61,9 +61,9 @@ def check_simulator_ostype(self, sdk, platform_name, 
arch=platform.machine()):
 
 # Older versions of watchOS (<7.0) only support i386
 if platform_name == "watchos":
-from pkg_resources import packaging
+from packaging.version import parse
 
-if packaging.version.parse(vers) < packaging.version.parse("7.0"):
+if parse(vers) < parse("7.0"):
 arch = "i386"
 
 triple = "-".join([arch, "apple", platform_name + vers, "simulator"])
diff --git a/lldb/test/Shell/helper/build.py b/lldb/test/Shell/helper/build.py
index d3c25bd944e98..9db2b133483a8 100755
--- a/lldb/test/Shell/helper/build.py
+++ b/lldb/test/Shell/helper/build.py
@@ -519,9 +519,9 @@ def _find_windows_sdk_in_registry_view(self, view):
 
 # Windows SDK version numbers consist of 4 dotted components, so we
 # have to use LooseVersion, as StrictVersion supports 3 or fewer.
-from pkg_resources import packaging
+from packaging.version import parse
 
-sdk_versions.sort(key=lambda x: packaging.version.parse(x), 
reverse=True)
+sdk_versions.sort(key=lambda x: parse(x), reverse=True)
 option_value_name = "OptionId.DesktopCPP" + self.msvc_arch_str
 for v in sdk_versions:
 try:

``




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


[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-29 Thread Miro Bucko via lldb-commits

mbucko wrote:

If the a.out is not there then the address was not resolved, I will investigate.

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


[Lldb-commits] [lldb] [lldb] Use packaging module instead of pkg_resources (PR #93712)

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

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/93712

Use the packaging [1] module for parsing version numbers, instead of 
pkg_resources which is distributed with setuptools. I recently switched over to 
using the latter, knowing it was deprecated (in favor of the packaging module) 
because it comes with Python out of the box. Newer versions of setuptools have 
removed `pkg_resources` so we have to use packaging.

[1] https://pypi.org/project/packaging/

>From fad874b04b1db121b8cab1a885882e1977264134 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Wed, 29 May 2024 10:36:47 -0700
Subject: [PATCH] [lldb] Use packaging module instead of pkg_resources

Use the packaging [1] module for parsing version numbers, instead of
pkg_resources which is distributed with setuptools. I recently switched
over to using the latter, knowing it was deprecated (in favor of the
packaging module) because it comes with Python out of the box. Newer
versions of setuptools have removed `pkg_resources` so we have to use
packaging.

[1] https://pypi.org/project/packaging/
---
 lldb/packages/Python/lldbsuite/test/decorators.py  | 6 ++
 lldb/packages/Python/lldbsuite/test/lldbplatformutil.py| 7 +++
 .../test/API/tools/lldb-server/TestAppleSimulatorOSType.py | 4 ++--
 lldb/test/Shell/helper/build.py| 4 ++--
 4 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 79cc0a2aeacbe..4b85219ce7c19 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1,6 +1,6 @@
 # System modules
 from functools import wraps
-from pkg_resources import packaging
+from packaging.version import parse
 import ctypes
 import locale
 import os
@@ -66,9 +66,7 @@ def fn_neq(x, y):
 "<=": fn_leq,
 }
 
-return op_lookup[comparison](
-packaging.version.parse(actual), packaging.version.parse(expected)
-)
+return op_lookup[comparison](parse(actual), parse(expected))
 
 
 def _match_decorator_property(expected, actual):
diff --git a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py 
b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
index 187d16aa1baa6..ecc814b016059 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbplatformutil.py
@@ -8,8 +8,7 @@
 import subprocess
 import sys
 import os
-from urllib.parse import urlparse
-from pkg_resources import packaging
+from packaging.version import parse
 
 # LLDB modules
 import lldb
@@ -309,8 +308,8 @@ def expectedCompilerVersion(compiler_version):
 # Assume the compiler version is at or near the top of trunk.
 return operator in [">", ">=", "!", "!=", "not"]
 
-version = packaging.version.parse(version_str)
-test_compiler_version = packaging.version.parse(test_compiler_version_str)
+version = parse(version_str)
+test_compiler_version = parse(test_compiler_version_str)
 
 if operator == ">":
 return test_compiler_version > version
diff --git a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py 
b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
index d770447f0771c..6dd838dab168b 100644
--- a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -61,9 +61,9 @@ def check_simulator_ostype(self, sdk, platform_name, 
arch=platform.machine()):
 
 # Older versions of watchOS (<7.0) only support i386
 if platform_name == "watchos":
-from pkg_resources import packaging
+from packaging.version import parse
 
-if packaging.version.parse(vers) < packaging.version.parse("7.0"):
+if parse(vers) < parse("7.0"):
 arch = "i386"
 
 triple = "-".join([arch, "apple", platform_name + vers, "simulator"])
diff --git a/lldb/test/Shell/helper/build.py b/lldb/test/Shell/helper/build.py
index d3c25bd944e98..9db2b133483a8 100755
--- a/lldb/test/Shell/helper/build.py
+++ b/lldb/test/Shell/helper/build.py
@@ -519,9 +519,9 @@ def _find_windows_sdk_in_registry_view(self, view):
 
 # Windows SDK version numbers consist of 4 dotted components, so we
 # have to use LooseVersion, as StrictVersion supports 3 or fewer.
-from pkg_resources import packaging
+from packaging.version import parse
 
-sdk_versions.sort(key=lambda x: packaging.version.parse(x), 
reverse=True)
+sdk_versions.sort(key=lambda x: parse(x), reverse=True)
 option_value_name = "OptionId.DesktopCPP" + self.msvc_arch_str
 for v in sdk_versions:
 try:

___
lldb-commits mailing list
lldb-commits@lists.llvm.org

[Lldb-commits] [lldb] [lldb][test] Fix formatter tests for clang version 15 (PR #93710)

2024-05-29 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Miro Bucko (mbucko)


Changes

Summary:

Test Plan:
ninja check-lldb

Reviewers:
clayborg

Subscribers:

Tasks:

Tags:

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


15 Files Affected:

- (modified) 
lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
 (+1-1) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
 (+1-1) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
 (+1-1) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py
 (+1-1) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
 (+1-1) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/list/TestListFromStdModule.py
 (+1-1) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py
 (+1-1) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/queue/TestQueueFromStdModule.py
 (+2-2) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/retry-with-std-module/TestRetryWithStdModule.py
 (+1-1) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/unique_ptr-dbg-info-content/TestUniquePtrDbgInfoContent.py
 (+1-1) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/unique_ptr/TestUniquePtrFromStdModule.py
 (+1-1) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
 (+1-1) 
- (modified) 
lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py
 (+1-1) 
- (modified) 
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
 (+2-2) 


``diff
diff --git 
a/lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
index 9e2fc17fa10b4..4168570f38c70 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
@@ -20,7 +20,7 @@ def test(self):
 self.runCmd("settings set target.import-std-module true")
 
 if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(
-[">", "16.0"]
+[">", "14.0"]
 ):
 deque_type = "std::deque"
 else:
diff --git 
a/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
index 24b1e00de67c7..cf11668290eee 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
@@ -21,7 +21,7 @@ def test(self):
 self.runCmd("settings set target.import-std-module true")
 
 if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(
-[">", "16.0"]
+[">", "14.0"]
 ):
 deque_type = "std::deque"
 else:
diff --git 
a/lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
index 9b0ca8c49f003..1a146767cc1f8 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
@@ -20,7 +20,7 @@ def test(self):
 self.runCmd("settings set target.import-std-module true")
 
 if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(
-[">", "16.0"]
+[">", "14.0"]
 ):
 list_type = "std::forward_list"
 else:
diff --git 
a/lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py
index 10dd8ee01081c..c7382220883a9 100644
--- 

[Lldb-commits] [lldb] [lldb][test] Fix formatter tests for clang version 15 (PR #93710)

2024-05-29 Thread Miro Bucko via lldb-commits

https://github.com/mbucko created 
https://github.com/llvm/llvm-project/pull/93710

Summary:

Test Plan:
ninja check-lldb

Reviewers:
clayborg

Subscribers:

Tasks:

Tags:

>From b6c70ac7b4c479fcdeb5d5c8b06da5a16ae468c4 Mon Sep 17 00:00:00 2001
From: Miro Bucko 
Date: Wed, 29 May 2024 10:28:16 -0700
Subject: [PATCH] [lldb][test] Fix formatter tests for clang version 15

Summary:

Test Plan:
ninja check-lldb

Reviewers:
clayborg

Subscribers:

Tasks:

Tags:
---
 .../import-std-module/deque-basic/TestDequeFromStdModule.py   | 2 +-
 .../TestDbgInfoContentDequeFromStdModule.py   | 2 +-
 .../TestDbgInfoContentForwardListFromStdModule.py | 2 +-
 .../forward_list/TestForwardListFromStdModule.py  | 2 +-
 .../TestDbgInfoContentListFromStdModule.py| 2 +-
 .../import-std-module/list/TestListFromStdModule.py   | 2 +-
 .../non-module-type-separation/TestNonModuleTypeSeparation.py | 2 +-
 .../import-std-module/queue/TestQueueFromStdModule.py | 4 ++--
 .../retry-with-std-module/TestRetryWithStdModule.py   | 2 +-
 .../TestUniquePtrDbgInfoContent.py| 2 +-
 .../unique_ptr/TestUniquePtrFromStdModule.py  | 2 +-
 .../TestDbgInfoContentVectorFromStdModule.py  | 2 +-
 .../vector-of-vectors/TestVectorOfVectorsFromStdModule.py | 2 +-
 .../libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py | 2 +-
 .../libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py | 4 ++--
 15 files changed, 17 insertions(+), 17 deletions(-)

diff --git 
a/lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
index 9e2fc17fa10b4..4168570f38c70 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/deque-basic/TestDequeFromStdModule.py
@@ -20,7 +20,7 @@ def test(self):
 self.runCmd("settings set target.import-std-module true")
 
 if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(
-[">", "16.0"]
+[">", "14.0"]
 ):
 deque_type = "std::deque"
 else:
diff --git 
a/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
index 24b1e00de67c7..cf11668290eee 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/TestDbgInfoContentDequeFromStdModule.py
@@ -21,7 +21,7 @@ def test(self):
 self.runCmd("settings set target.import-std-module true")
 
 if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(
-[">", "16.0"]
+[">", "14.0"]
 ):
 deque_type = "std::deque"
 else:
diff --git 
a/lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
index 9b0ca8c49f003..1a146767cc1f8 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
@@ -20,7 +20,7 @@ def test(self):
 self.runCmd("settings set target.import-std-module true")
 
 if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(
-[">", "16.0"]
+[">", "14.0"]
 ):
 list_type = "std::forward_list"
 else:
diff --git 
a/lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py
 
b/lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py
index 10dd8ee01081c..c7382220883a9 100644
--- 
a/lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py
+++ 
b/lldb/test/API/commands/expression/import-std-module/forward_list/TestForwardListFromStdModule.py
@@ -20,7 +20,7 @@ def test(self):
 self.runCmd("settings set target.import-std-module true")
 
 if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion(
-[">", "16.0"]
+[">", "14.0"]
 ):
 list_type = "std::forward_list"
 else:
diff --git 
a/lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/TestDbgInfoContentListFromStdModule.py
 

[Lldb-commits] [lldb] [nfc][lldb] Move FastSearch from CommandObjectMemoryFind to Process (PR #93688)

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

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


[Lldb-commits] [lldb] 2655897 - [nfc][lldb] Move FastSearch from CommandObjectMemoryFind to Process (#93688)

2024-05-29 Thread via lldb-commits

Author: Miro Bucko
Date: 2024-05-29T10:37:57-07:00
New Revision: 265589785ccf043492e4e0ab88c2830eae7d3496

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

LOG: [nfc][lldb] Move FastSearch from CommandObjectMemoryFind to Process 
(#93688)

Moving CommandObjectMemoryFind::FastSearch() to Process::FindInMemory(). Plan 
to expose FindInMemory as public API in SBProcess.

Added: 


Modified: 
lldb/include/lldb/Target/Process.h
lldb/source/Commands/CommandObjectMemory.cpp
lldb/source/Target/Process.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 637d34c29715c..eec337c15f7ed 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -2663,6 +2663,28 @@ void PruneThreadPlans();
 return m_source_file_cache;
   }
 
+  /// Find a pattern within a memory region.
+  ///
+  /// This function searches for a pattern represented by the provided buffer
+  /// within the memory range specified by the low and high addresses. It uses
+  /// a bad character heuristic to optimize the search process.
+  ///
+  /// \param[in] low The starting address of the memory region to be searched.
+  /// (inclusive)
+  ///
+  /// \param[in] high The ending address of the memory region to be searched.
+  /// (exclusive)
+  ///
+  /// \param[in] buf A pointer to the buffer containing the pattern to be
+  /// searched.
+  ///
+  /// \param[in] buffer_size The size of the buffer in bytes.
+  ///
+  /// \return The address where the pattern was found or LLDB_INVALID_ADDRESS 
if
+  /// not found.
+  lldb::addr_t FindInMemory(lldb::addr_t low, lldb::addr_t high,
+const uint8_t *buf, size_t size);
+
 protected:
   friend class Trace;
 

diff  --git a/lldb/source/Commands/CommandObjectMemory.cpp 
b/lldb/source/Commands/CommandObjectMemory.cpp
index b78a0492cca55..1c13484dede64 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -977,35 +977,6 @@ class CommandObjectMemoryFind : public CommandObjectParsed 
{
   Options *GetOptions() override { return _option_group; }
 
 protected:
-  class ProcessMemoryIterator {
-  public:
-ProcessMemoryIterator(ProcessSP process_sp, lldb::addr_t base)
-: m_process_sp(process_sp), m_base_addr(base) {
-  lldbassert(process_sp.get() != nullptr);
-}
-
-bool IsValid() { return m_is_valid; }
-
-uint8_t operator[](lldb::addr_t offset) {
-  if (!IsValid())
-return 0;
-
-  uint8_t retval = 0;
-  Status error;
-  if (0 ==
-  m_process_sp->ReadMemory(m_base_addr + offset, , 1, error)) {
-m_is_valid = false;
-return 0;
-  }
-
-  return retval;
-}
-
-  private:
-ProcessSP m_process_sp;
-lldb::addr_t m_base_addr;
-bool m_is_valid = true;
-  };
   void DoExecute(Args , CommandReturnObject ) override {
 // No need to check "process" for validity as eCommandRequiresProcess
 // ensures it is valid
@@ -1106,8 +1077,8 @@ class CommandObjectMemoryFind : public 
CommandObjectParsed {
 found_location = low_addr;
 bool ever_found = false;
 while (count) {
-  found_location = FastSearch(found_location, high_addr, buffer.GetBytes(),
-  buffer.GetByteSize());
+  found_location = process->FindInMemory(
+  found_location, high_addr, buffer.GetBytes(), buffer.GetByteSize());
   if (found_location == LLDB_INVALID_ADDRESS) {
 if (!ever_found) {
   result.AppendMessage("data not found within the range.\n");
@@ -1144,34 +1115,6 @@ class CommandObjectMemoryFind : public 
CommandObjectParsed {
 result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
   }
 
-  lldb::addr_t FastSearch(lldb::addr_t low, lldb::addr_t high, uint8_t *buffer,
-  size_t buffer_size) {
-const size_t region_size = high - low;
-
-if (region_size < buffer_size)
-  return LLDB_INVALID_ADDRESS;
-
-std::vector bad_char_heuristic(256, buffer_size);
-ProcessSP process_sp = m_exe_ctx.GetProcessSP();
-ProcessMemoryIterator iterator(process_sp, low);
-
-for (size_t idx = 0; idx < buffer_size - 1; idx++) {
-  decltype(bad_char_heuristic)::size_type bcu_idx = buffer[idx];
-  bad_char_heuristic[bcu_idx] = buffer_size - idx - 1;
-}
-for (size_t s = 0; s <= (region_size - buffer_size);) {
-  int64_t j = buffer_size - 1;
-  while (j >= 0 && buffer[j] == iterator[s + j])
-j--;
-  if (j < 0)
-return low + s;
-  else
-s += bad_char_heuristic[iterator[s + buffer_size - 1]];
-}
-
-return LLDB_INVALID_ADDRESS;
-  }
-
   OptionGroupOptions m_option_group;
   

[Lldb-commits] [lldb] [nfc][lldb] Move FastSearch from CommandObjectMemoryFind to Process (PR #93688)

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

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


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


[Lldb-commits] [lldb] [nfc][lldb] Move FastSearch from CommandObjectMemoryFind to Process (PR #93688)

2024-05-29 Thread via lldb-commits

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

It's not a good idea in general to have useful algorithms in the 
CommandObjects, that leads to code duplication - people can't be expected to 
scour the CommandObjects for stealable code  So this sort of move is a good 
tidying up even if you didn't plan to use it somewhere else.

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


[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-29 Thread Michael Buch via lldb-commits

Michael137 wrote:

FYI, the `TestAddressRange` tests are failing on the macOS buildbots: 
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/4764/execution/node/97/log/
```
==
FAIL: test_address_range_print_resolved (TestAddressRange.AddressRangeTestCase)
Make sure the SBAddressRange can be printed when resolved.
--
Traceback (most recent call last):
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/python_api/address_range/TestAddressRange.py",
 line 186, in test_address_range_print_resolved
self.assertRegex(range_str, "^\[0x[0-9a-f]+\-0x[0-9a-f]+\)$")
AssertionError: Regex didn't match: '^\\[0x[0-9a-f]+\\-0x[0-9a-f]+\\)$' not 
found in 'a.out[0x13f70-0x13fa0)'
```
Seems like we just didn't account for the `a.out` prefix here?

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


[Lldb-commits] [lldb] [lldb] Update LLDB testsuite's Makefile.rules in order to support the cross builds on Windows host. (PR #93639)

2024-05-29 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Vladimir Vereschaka (vvereschaka)


Changes

These changes do the following:

* avoids usage of $(findstring) within $(CC) to detect a type of specified C 
compiler. Also they change a way to get a counterpart C++ compiler instead of 
modifying the original $(CC) variable. Both of those fixes a problem when a 
compiler name is a part of some word (or itself) used in the path to the 
compiler. Here is an example where the `cc` compiler is getting detected 
instead of `clang` compiler inside of $(CC) with the following path:

 `".../accesssoftek/.../bin/clang.exe"`

and replaces the 'cc' sequence of 'accesssoftek' word with 'c++' sequence to 
get the C++ compiler name:

 `".../ac++esssoftek/.../bin/clang.exe"`

The change parses the source $(CC) and put every part into a separate variable 
instead and uses these parts to build the required tool's references 
subsequently.

Also these parts are used within the conditions to direct comparison instead of 
using $(findstring) where it is necessary or possible.

* avoids the compiler comparison with $(findstring) within the conditions.
* fixes SHELL initialization on the Windows build hosts.
* moves LLVM_AR initialization from the test's Makefile into Makefile.rules.
* adds `USE_LLVM_TOOLS` variable to force using of llvm-ar/llvm-objcopy tool 
instead of the system default. Passing this variable as `USE_LLVM_TOOLS=1` will 
configure the build to use `llvm-ar`, `llvm-objcopy` and `llvm-strip` tools for 
the tests. This variable could be passed via 
`LLDB_TEST_USER_ARGS="...;--env;USE_LLVM_TOOL=1;..."`.
* fix of LDFLAGS guiding through Makefile.rules.


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


1 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/make/Makefile.rules (+176-84) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index bd8eea3d6f5a0..8cf67068af34d 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -26,6 +26,9 @@
 # SPLIT_DEBUG_SYMBOLS := YES
 # CROSS_COMPILE :=
 # USE_PRIVATE_MODULE_CACHE := YES
+#
+# Specifying USE_LLVM_TOOLS=1 will force usage of the LLVM tools, such as 
llvm-ar/llvm-objcopy/llvm-strip,
+# instead of the system defaults (ar/objcopy/strip accordingly).
 
 # Uncomment line below for debugging shell commands
 # SHELL = /bin/sh -x
@@ -39,6 +42,11 @@ MAKEFILE_RULES := $(lastword $(MAKEFILE_LIST))
 THIS_FILE_DIR := $(shell dirname $(MAKEFILE_RULES))
 LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 
+STRIP ?= strip
+
+# Empty if not specified.
+LDFLAGS ?=
+
 # The test harness invokes the test Makefiles with an explicit 'all'
 # target, but its handy to be able to recursively call this Makefile
 # without specifying a goal. You almost certainly want to build 'all',
@@ -51,23 +59,25 @@ 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.
 #--
 HOST_OS := $(shell uname -s)
-ifneq (,$(findstring windows32,$(HOST_OS)))
-   HOST_OS := Windows_NT
-endif
-
-ifneq (,$(findstring MSYS_NT,$(HOST_OS)))
-   HOST_OS := Windows_NT
+ifneq (,$(or \
+$(findstring windows32,$(HOST_OS)),\
+$(findstring MSYS_NT,$(HOST_OS
+HOST_OS := Windows_NT
 endif
 
 ifeq "$(OS)" ""
OS := $(HOST_OS)
 endif
 
+# Retrieve the host arch. We are going to use $HOST_OS/$HOST_ARCH to
+# detect the cross platform testing.
+HOST_ARCH := $(shell uname -m)
+
 #--
 # If OS is Windows, force SHELL to be cmd
 #
@@ -77,9 +87,10 @@ endif
 # Also reset BUILDDIR value because "pwd" returns cygwin or msys path
 # which needs to be converted to windows path.
 #--
-ifeq "$(OS)" "Windows_NT"
-   SHELL = $(WINDIR)\system32\cmd.exe
-   BUILDDIR := $(shell echo %cd%)
+ifeq "$(HOST_OS)" "Windows_NT"
+# The latest Windows has the lower-case 'windir' env variable.
+SHELL := $(or $(windir),$(WINDIR),C:\WINDOWS)\system32\cmd.exe
+BUILDDIR := $(shell echo %cd%)
 endif
 
 #--
@@ -91,16 +102,18 @@ endif
 ifeq "$(HOST_OS)" "Windows_NT"
QUOTE = "
FIXUP_SYNTAX_HIGHLIGHTING_IN_MY_EDITOR = "
+EXE_EXT := .exe
 else
QUOTE = '
FIXUP_SYNTAX_HIGHLIGHTING_IN_MY_EDITOR = '
+

[Lldb-commits] [lldb] [lldb][lldb-dap] Cleanup breakpoint filters. (PR #87550)

2024-05-29 Thread Vy Nguyen via lldb-commits

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


[Lldb-commits] [lldb] cfb209b - [lldb][lldb-dap] Cleanup breakpoint filters. (#87550)

2024-05-29 Thread via lldb-commits

Author: Vy Nguyen
Date: 2024-05-29T12:22:42-04:00
New Revision: cfb209b92a26f16ed7413b32da20fc436eff8c58

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

LOG: [lldb][lldb-dap] Cleanup breakpoint filters. (#87550)

Details:
- remove Swift breakpoint filter because this version of LLDB does not
support Swift.
  - only return objc filters when working on macos.

Added: 


Modified: 
lldb/include/lldb/API/SBDebugger.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/API/SBDebugger.cpp
lldb/source/Symbol/TypeSystem.cpp
lldb/tools/lldb-dap/DAP.cpp
lldb/tools/lldb-dap/DAP.h
lldb/tools/lldb-dap/lldb-dap.cpp

Removed: 




diff  --git a/lldb/include/lldb/API/SBDebugger.h 
b/lldb/include/lldb/API/SBDebugger.h
index af19b1faf3bf5..84ea9c0f772e1 100644
--- a/lldb/include/lldb/API/SBDebugger.h
+++ b/lldb/include/lldb/API/SBDebugger.h
@@ -57,6 +57,8 @@ class LLDB_API SBDebugger {
 
   static const char *GetBroadcasterClass();
 
+  static bool SupportsLanguage(lldb::LanguageType language);
+
   lldb::SBBroadcaster GetBroadcaster();
 
   /// Get progress data from a SBEvent whose type is eBroadcastBitProgress.

diff  --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index b4025c173a186..7d48f9b316138 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -209,6 +209,7 @@ class TypeSystem : public PluginInterface,
   // TypeSystems can support more than one language
   virtual bool SupportsLanguage(lldb::LanguageType language) = 0;
 
+  static bool SupportsLanguageStatic(lldb::LanguageType language);
   // Type Completion
 
   virtual bool GetCompleteType(lldb::opaque_compiler_type_t type) = 0;

diff  --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index 7ef0d6efd4aaa..29da7d33dd80b 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -1742,3 +1742,7 @@ bool SBDebugger::InterruptRequested()   {
 return m_opaque_sp->InterruptRequested();
   return false;
 }
+
+bool SBDebugger::SupportsLanguage(lldb::LanguageType language) {
+  return TypeSystem::SupportsLanguageStatic(language);
+}

diff  --git a/lldb/source/Symbol/TypeSystem.cpp 
b/lldb/source/Symbol/TypeSystem.cpp
index 4956f10a0b0a7..5d56d9b1829da 100644
--- a/lldb/source/Symbol/TypeSystem.cpp
+++ b/lldb/source/Symbol/TypeSystem.cpp
@@ -335,3 +335,14 @@ TypeSystemMap::GetTypeSystemForLanguage(lldb::LanguageType 
language,
   }
   return GetTypeSystemForLanguage(language);
 }
+
+bool TypeSystem::SupportsLanguageStatic(lldb::LanguageType language) {
+  if (language == eLanguageTypeUnknown)
+return false;
+
+  LanguageSet languages =
+  PluginManager::GetAllTypeSystemSupportedLanguagesForTypes();
+  if (languages.Empty())
+return false;
+  return languages[language];
+}

diff  --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index d419f821999e6..807d27c2c869d 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -32,14 +32,7 @@ namespace lldb_dap {
 DAP g_dap;
 
 DAP::DAP()
-: broadcaster("lldb-dap"),
-  exception_breakpoints(
-  {{"cpp_catch", "C++ Catch", lldb::eLanguageTypeC_plus_plus},
-   {"cpp_throw", "C++ Throw", lldb::eLanguageTypeC_plus_plus},
-   {"objc_catch", "Objective-C Catch", lldb::eLanguageTypeObjC},
-   {"objc_throw", "Objective-C Throw", lldb::eLanguageTypeObjC},
-   {"swift_catch", "Swift Catch", lldb::eLanguageTypeSwift},
-   {"swift_throw", "Swift Throw", lldb::eLanguageTypeSwift}}),
+: broadcaster("lldb-dap"), exception_breakpoints(),
   focus_tid(LLDB_INVALID_THREAD_ID), stop_at_entry(false), 
is_attach(false),
   enable_auto_variable_summaries(false),
   enable_synthetic_child_debugging(false),
@@ -65,8 +58,32 @@ DAP::DAP()
 
 DAP::~DAP() = default;
 
+void DAP::PopulateExceptionBreakpoints() {
+  exception_breakpoints = {};
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeC_plus_plus)) {
+exception_breakpoints->emplace_back("cpp_catch", "C++ Catch",
+lldb::eLanguageTypeC_plus_plus);
+exception_breakpoints->emplace_back("cpp_throw", "C++ Throw",
+lldb::eLanguageTypeC_plus_plus);
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeObjC)) {
+exception_breakpoints->emplace_back("objc_catch", "Objective-C Catch",
+lldb::eLanguageTypeObjC);
+exception_breakpoints->emplace_back("objc_throw", "Objective-C Throw",
+lldb::eLanguageTypeObjC);
+  }
+  if (debugger.SupportsLanguage(lldb::eLanguageTypeSwift)) {
+exception_breakpoints->emplace_back("swift_catch", 

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

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

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

LGTM! 

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] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

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

felipepiovezan wrote:

thanks for well-written summary @dwblaikie !

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] Improve performance of .debug_names lookups when DW_IDX_parent attributes are used (PR #91808)

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

felipepiovezan wrote:

> > Discussed with Pavel, I applied this change to #92328 so we can ensure the 
> > DIEs from the index is always definition DIEs and avoid duplicate/expensive 
> > checks later.
> 
> To elaborate, I suggested Zequan does this, because I think there's consensus 
> that this is a good way to filter out (incorrect) declaration dies from the 
> index, and it's a better (faster) fix than what Zequan had in his PR. It's 
> still worthwhile to figure out where those entries are coming from. We know 
> of one case with type units and that has now been fixed (thanks to David), if 
> there are more, we should try to understand where they are coming from).

Sounds good! 

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] fe82a3d - Revert "[Support] Remove terminfo dependency (#92865)"

2024-05-29 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2024-05-29T16:20:42+01:00
New Revision: fe82a3da36196157c0caa1ef2505186782f750d1

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

LOG: Revert "[Support] Remove terminfo dependency (#92865)"

This reverts commit 6bf450c7a60fa62c642e39836566da94bb9bbc91.

It breaks LLDB CI: 
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/4762/execution/node/97/log/

```
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
 -Wdocumentation -fPIC -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing 
-Wno-deprecated-register -Wno-vla-extension -O3 -DNDEBUG -arch arm64 -isysroot 
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk
 -mmacosx-version-min=14.1 -Wl,-search_paths_first 
-Wl,-headerpad_max_install_names -Wl,-dead_strip 
-Wl,-no_warn_duplicate_libraries 
tools/lldb/unittests/Editline/CMakeFiles/EditlineTests.dir/EditlineTest.cpp.o 
-o tools/lldb/unittests/Editline/EditlineTests  lib/libLLVMSupport.a  
lib/libllvm_gtest_main.a  lib/libllvm_gtest.a  lib/liblldbHost.a  
lib/liblldbUtility.a  lib/libLLVMTestingSupport.a  
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libxml2.tbd
  
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libedit.tbd
  lib/liblldbHostMacOSXObjCXX.a  lib/liblldbUtility.a  -framework Foundation  
-framework CoreFoundation  -framework CoreServices  -framework Security  
lib/libLLVMObject.a  lib/libLLVMIRReader.a  lib/libLLVMBitReader.a  
lib/libLLVMAsmParser.a  lib/libLLVMCore.a  lib/libLLVMRemarks.a  
lib/libLLVMBitstreamReader.a  lib/libLLVMMCParser.a  lib/libLLVMMC.a  
lib/libLLVMDebugInfoCodeView.a  lib/libLLVMTextAPI.a  lib/libLLVMBinaryFormat.a 
 lib/libLLVMTargetParser.a  lib/libllvm_gtest.a  lib/libLLVMSupport.a  -lm  
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/usr/lib/libz.tbd
  /opt/homebrew/lib/libzstd.dylib  lib/libLLVMDemangle.a  -lpthread && cd 
/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/tools/lldb/unittests/Editline
 && /opt/homebrew/Cellar/cmake/3.28.3/bin/cmake -E make_directory 
/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/tools/lldb/unittests/Editline/./Inputs
ld: Undefined symbols:
  _setupterm, referenced from:
  lldb_private::Editline::Editline(char const*, __sFILE*, __sFILE*, 
__sFILE*, std::__1::recursive_mutex&) in liblldbHost.a[35](Editline.cpp.o)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

Added: 
llvm/cmake/modules/FindTerminfo.cmake
llvm/utils/gn/build/libs/terminfo/BUILD.gn
llvm/utils/gn/build/libs/terminfo/enable.gni

Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake
clang/cmake/caches/Fuchsia.cmake
clang/cmake/caches/VectorEngine.cmake
clang/utils/analyzer/entrypoint.py
compiler-rt/cmake/config-ix.cmake
compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
compiler-rt/lib/xray/tests/CMakeLists.txt
lldb/docs/resources/build.rst
lldb/source/Core/CMakeLists.txt
llvm/CMakeLists.txt
llvm/cmake/config-ix.cmake
llvm/cmake/modules/LLVMConfig.cmake.in
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/Config/config.h.cmake
llvm/lib/Support/CMakeLists.txt
llvm/lib/Support/Unix/Process.inc
llvm/utils/gn/README.rst
llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn
llvm/utils/gn/secondary/llvm/lib/Support/BUILD.gn
llvm/utils/gn/secondary/llvm/tools/llvm-config/BUILD.gn
utils/bazel/.bazelrc
utils/bazel/llvm-project-overlay/llvm/include/llvm/Config/config.h
utils/bazel/llvm_configs/config.h.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 66e764968e85ce..d5546e20873b3c 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -19,6 +19,7 @@ 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 

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

2024-05-29 Thread Michael Buch via lldb-commits

Michael137 wrote:

I'm going to revert this for now until since the bots have been red for a while 
now

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


[Lldb-commits] [lldb] [lldb] Add register field enum class (PR #90063)

2024-05-29 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Rebased to include 
https://github.com/llvm/llvm-project/commit/799316ff26cc82d60f276dc62c4a69b5bba1aef3
 and have addressed the open comments.

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


[Lldb-commits] [lldb] [lldb] Add register field enum class (PR #90063)

2024-05-29 Thread David Spickett via lldb-commits


@@ -13,11 +13,42 @@
 #include 
 #include 
 
+#include "llvm/ADT/StringSet.h"
+
 namespace lldb_private {
 
 class StreamString;
 class Log;
 
+class FieldEnum {
+public:
+  struct Enumerator {
+uint64_t m_value;
+// Short name for the value. Shown in tables and when printing the field's
+// value. For example "RZ".
+std::string m_name;
+
+Enumerator(uint64_t value, std::string name)
+: m_value(value), m_name(name) {}

DavidSpickett wrote:

Done.

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


[Lldb-commits] [lldb] [lldb] Add register field enum class (PR #90063)

2024-05-29 Thread David Spickett via lldb-commits


@@ -13,11 +13,42 @@
 #include 
 #include 
 
+#include "llvm/ADT/StringSet.h"
+
 namespace lldb_private {
 
 class StreamString;
 class Log;
 
+class FieldEnum {
+public:
+  struct Enumerator {
+uint64_t m_value;
+// Short name for the value. Shown in tables and when printing the field's
+// value. For example "RZ".
+std::string m_name;
+
+Enumerator(uint64_t value, std::string name)
+: m_value(value), m_name(name) {}
+
+void ToXML(StreamString ) const;
+  };
+
+  typedef std::vector Enumerators;
+
+  FieldEnum(std::string id, const Enumerators );
+
+  const Enumerators () const { return m_enumerators; }
+
+  const std::string () const { return m_id; }
+
+  void ToXML(StreamString , unsigned size) const;

DavidSpickett wrote:

Done.

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


[Lldb-commits] [lldb] [lldb] Add register field enum class (PR #90063)

2024-05-29 Thread David Spickett via lldb-commits


@@ -13,11 +13,42 @@
 #include 
 #include 
 
+#include "llvm/ADT/StringSet.h"
+
 namespace lldb_private {
 
 class StreamString;
 class Log;
 
+class FieldEnum {
+public:
+  struct Enumerator {
+uint64_t m_value;
+// Short name for the value. Shown in tables and when printing the field's
+// value. For example "RZ".
+std::string m_name;
+
+Enumerator(uint64_t value, std::string name)
+: m_value(value), m_name(name) {}
+
+void ToXML(StreamString ) const;
+  };
+
+  typedef std::vector Enumerators;
+
+  FieldEnum(std::string id, const Enumerators );
+
+  const Enumerators () const { return m_enumerators; }
+
+  const std::string () const { return m_id; }
+
+  void ToXML(StreamString , unsigned size) const;
+
+private:
+  std::string m_id;
+  std::vector m_enumerators;

DavidSpickett wrote:

Done.

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


[Lldb-commits] [lldb] [lldb] Add register field enum class (PR #90063)

2024-05-29 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett updated 
https://github.com/llvm/llvm-project/pull/90063

>From 722704c323a68d426e127308f8e247fb7f94e414 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 11 Mar 2024 10:51:22 +
Subject: [PATCH] [lldb] Add register field enum class

This represents the enum type that can be assigned to a field
using the `` element in the target XML.

https://sourceware.org/gdb/current/onlinedocs/gdb.html/Enum-Target-Types.html

Each enumerator has:
* A non-empty name
* A value that is within the range of the field it's applied to

The XML includes a "size" but we don't need that for anything
and it's a pain to verify so I've left it out of our internal
strcutures. When emitting XML we'll set size to the size of
the register using the enum.

An Enumerator class is added to RegisterFlags and hooked up
to the existing ToXML so lldb-server will include them in the
target XML.

As enums are elements on the same level as flags, when emitting
XML we'll do so via the registers. Before emitting a flags element
we look at all the fields and see what enums they refernce. Then
print all of those if we haven't already.

Functions are added to dump enum information for `register info`
to use to show the enum information.
---
 lldb/include/lldb/Target/RegisterFlags.h|  72 ++-
 lldb/source/Target/RegisterFlags.cpp| 198 +++-
 lldb/unittests/Target/RegisterFlagsTest.cpp | 175 -
 3 files changed, 435 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Target/RegisterFlags.h 
b/lldb/include/lldb/Target/RegisterFlags.h
index 29a47540cd4f5..1c6bf5dcf4a7f 100644
--- a/lldb/include/lldb/Target/RegisterFlags.h
+++ b/lldb/include/lldb/Target/RegisterFlags.h
@@ -13,11 +13,42 @@
 #include 
 #include 
 
+#include "llvm/ADT/StringSet.h"
+
 namespace lldb_private {
 
 class Stream;
 class Log;
 
+class FieldEnum {
+public:
+  struct Enumerator {
+uint64_t m_value;
+// Short name for the value. Shown in tables and when printing the field's
+// value. For example "RZ".
+std::string m_name;
+
+Enumerator(uint64_t value, std::string name)
+: m_value(value), m_name(std::move(name)) {}
+
+void ToXML(Stream ) const;
+  };
+
+  typedef std::vector Enumerators;
+
+  FieldEnum(std::string id, const Enumerators );
+
+  const Enumerators () const { return m_enumerators; }
+
+  const std::string () const { return m_id; }
+
+  void ToXML(Stream , unsigned size) const;
+
+private:
+  std::string m_id;
+  Enumerators m_enumerators;
+};
+
 class RegisterFlags {
 public:
   class Field {
@@ -26,17 +57,27 @@ class RegisterFlags {
 /// significant bit. The start bit must be <= the end bit.
 Field(std::string name, unsigned start, unsigned end);
 
+/// Construct a field that also has some known enum values.
+Field(std::string name, unsigned start, unsigned end,
+  const FieldEnum *enum_type);
+
 /// Construct a field that occupies a single bit.
-Field(std::string name, unsigned bit_position)
-: m_name(std::move(name)), m_start(bit_position), m_end(bit_position) 
{}
+Field(std::string name, unsigned bit_position);
 
 /// Get size of the field in bits. Will always be at least 1.
-unsigned GetSizeInBits() const { return m_end - m_start + 1; }
+unsigned GetSizeInBits() const;
+
+/// Identical to GetSizeInBits, but for the GDB client to use.
+static unsigned GetSizeInBits(unsigned start, unsigned end);
 
 /// A mask that covers all bits of the field.
-uint64_t GetMask() const {
-  return (((uint64_t)1 << (GetSizeInBits())) - 1) << m_start;
-}
+uint64_t GetMask() const;
+
+/// The maximum unsigned value that could be contained in this field.
+uint64_t GetMaxValue() const;
+
+/// Identical to GetMaxValue but for the GDB client to use.
+static uint64_t GetMaxValue(unsigned start, unsigned end);
 
 /// Extract value of the field from a whole register value.
 uint64_t GetValue(uint64_t register_value) const {
@@ -46,6 +87,7 @@ class RegisterFlags {
 const std::string () const { return m_name; }
 unsigned GetStart() const { return m_start; }
 unsigned GetEnd() const { return m_end; }
+const FieldEnum *GetEnum() const { return m_enum_type; }
 bool Overlaps(const Field ) const;
 void log(Log *log) const;
 
@@ -69,12 +111,15 @@ class RegisterFlags {
 
   private:
 std::string m_name;
+
 /// Start/end bit positions. Where start N, end N means a single bit
 /// field at position N. We expect that start <= end. Bit positions begin
 /// at 0.
 /// Start is the LSB, end is the MSB.
 unsigned m_start;
 unsigned m_end;
+
+const FieldEnum *m_enum_type;
   };
 
   /// This assumes that:
@@ -89,6 +134,10 @@ class RegisterFlags {
   /// when runtime field detection is needed.
   void SetFields(const std::vector );
 
+  /// Make a string where each line contains the name of a field that has
+  /// enum 

[Lldb-commits] [lldb] 799316f - [lldb][NFC] Pass Stream& to ToXML methods in RegisterFlags

2024-05-29 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2024-05-29T14:27:30Z
New Revision: 799316ff26cc82d60f276dc62c4a69b5bba1aef3

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

LOG: [lldb][NFC] Pass Stream& to ToXML methods in RegisterFlags

As suggested in a review of some new code for this file, Stream
is more general. The code does not need to know that it's backed
by a string.

Added: 


Modified: 
lldb/include/lldb/Target/RegisterFlags.h
lldb/source/Target/RegisterFlags.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/RegisterFlags.h 
b/lldb/include/lldb/Target/RegisterFlags.h
index 9b343e445678a..29a47540cd4f5 100644
--- a/lldb/include/lldb/Target/RegisterFlags.h
+++ b/lldb/include/lldb/Target/RegisterFlags.h
@@ -15,7 +15,7 @@
 
 namespace lldb_private {
 
-class StreamString;
+class Stream;
 class Log;
 
 class RegisterFlags {
@@ -56,7 +56,7 @@ class RegisterFlags {
 /// Output XML that describes this field, to be inserted into a target XML
 /// file. Reserved characters in field names like "<" are replaced with
 /// their XML safe equivalents like "".
-void ToXML(StreamString ) const;
+void ToXML(Stream ) const;
 
 bool operator<(const Field ) const {
   return GetStart() < rhs.GetStart();
@@ -119,7 +119,7 @@ class RegisterFlags {
   std::string AsTable(uint32_t max_width) const;
 
   // Output XML that describes this set of flags.
-  void ToXML(StreamString ) const;
+  void ToXML(Stream ) const;
 
 private:
   const std::string m_id;

diff  --git a/lldb/source/Target/RegisterFlags.cpp 
b/lldb/source/Target/RegisterFlags.cpp
index b1669b85fd2fe..5274960587bf3 100644
--- a/lldb/source/Target/RegisterFlags.cpp
+++ b/lldb/source/Target/RegisterFlags.cpp
@@ -190,7 +190,7 @@ std::string RegisterFlags::AsTable(uint32_t max_width) 
const {
   return table;
 }
 
-void RegisterFlags::ToXML(StreamString ) const {
+void RegisterFlags::ToXML(Stream ) const {
   // Example XML:
   // 
   //   
@@ -213,7 +213,7 @@ void RegisterFlags::ToXML(StreamString ) const {
   strm.Indent("\n");
 }
 
-void RegisterFlags::Field::ToXML(StreamString ) const {
+void RegisterFlags::Field::ToXML(Stream ) const {
   // Example XML:
   // 
   strm.Indent();



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


[Lldb-commits] [lldb] [nfc][lldb] Move FastSearch from CommandObjectMemoryFind to Process (PR #93688)

2024-05-29 Thread Miro Bucko via lldb-commits

https://github.com/mbucko updated 
https://github.com/llvm/llvm-project/pull/93688

>From 6e461bef5a7f3bda3ff413168b3cc2a26b41cdb0 Mon Sep 17 00:00:00 2001
From: Miro Bucko 
Date: Wed, 29 May 2024 06:38:22 -0700
Subject: [PATCH] [nfc][lldb] Move FastSearch from CommandObjectMemoryFind to
 Process

Summary:
Moving CommandObjectMemoryFind::FastSearch() to Process::FindInMemory().
Plan to expose FindInMemory as public API in SBProcess.

Test Plan:
ninja check-lldb

Reviewers:

Subscribers:

Tasks:
lldb

Tags:
---
 lldb/include/lldb/Target/Process.h   | 22 +++
 lldb/source/Commands/CommandObjectMemory.cpp | 61 +---
 lldb/source/Target/Process.cpp   | 54 +
 3 files changed, 78 insertions(+), 59 deletions(-)

diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 637d34c29715c..eec337c15f7ed 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -2663,6 +2663,28 @@ void PruneThreadPlans();
 return m_source_file_cache;
   }
 
+  /// Find a pattern within a memory region.
+  ///
+  /// This function searches for a pattern represented by the provided buffer
+  /// within the memory range specified by the low and high addresses. It uses
+  /// a bad character heuristic to optimize the search process.
+  ///
+  /// \param[in] low The starting address of the memory region to be searched.
+  /// (inclusive)
+  ///
+  /// \param[in] high The ending address of the memory region to be searched.
+  /// (exclusive)
+  ///
+  /// \param[in] buf A pointer to the buffer containing the pattern to be
+  /// searched.
+  ///
+  /// \param[in] buffer_size The size of the buffer in bytes.
+  ///
+  /// \return The address where the pattern was found or LLDB_INVALID_ADDRESS 
if
+  /// not found.
+  lldb::addr_t FindInMemory(lldb::addr_t low, lldb::addr_t high,
+const uint8_t *buf, size_t size);
+
 protected:
   friend class Trace;
 
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp 
b/lldb/source/Commands/CommandObjectMemory.cpp
index b78a0492cca55..1c13484dede64 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -977,35 +977,6 @@ class CommandObjectMemoryFind : public CommandObjectParsed 
{
   Options *GetOptions() override { return _option_group; }
 
 protected:
-  class ProcessMemoryIterator {
-  public:
-ProcessMemoryIterator(ProcessSP process_sp, lldb::addr_t base)
-: m_process_sp(process_sp), m_base_addr(base) {
-  lldbassert(process_sp.get() != nullptr);
-}
-
-bool IsValid() { return m_is_valid; }
-
-uint8_t operator[](lldb::addr_t offset) {
-  if (!IsValid())
-return 0;
-
-  uint8_t retval = 0;
-  Status error;
-  if (0 ==
-  m_process_sp->ReadMemory(m_base_addr + offset, , 1, error)) {
-m_is_valid = false;
-return 0;
-  }
-
-  return retval;
-}
-
-  private:
-ProcessSP m_process_sp;
-lldb::addr_t m_base_addr;
-bool m_is_valid = true;
-  };
   void DoExecute(Args , CommandReturnObject ) override {
 // No need to check "process" for validity as eCommandRequiresProcess
 // ensures it is valid
@@ -1106,8 +1077,8 @@ class CommandObjectMemoryFind : public 
CommandObjectParsed {
 found_location = low_addr;
 bool ever_found = false;
 while (count) {
-  found_location = FastSearch(found_location, high_addr, buffer.GetBytes(),
-  buffer.GetByteSize());
+  found_location = process->FindInMemory(
+  found_location, high_addr, buffer.GetBytes(), buffer.GetByteSize());
   if (found_location == LLDB_INVALID_ADDRESS) {
 if (!ever_found) {
   result.AppendMessage("data not found within the range.\n");
@@ -1144,34 +1115,6 @@ class CommandObjectMemoryFind : public 
CommandObjectParsed {
 result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
   }
 
-  lldb::addr_t FastSearch(lldb::addr_t low, lldb::addr_t high, uint8_t *buffer,
-  size_t buffer_size) {
-const size_t region_size = high - low;
-
-if (region_size < buffer_size)
-  return LLDB_INVALID_ADDRESS;
-
-std::vector bad_char_heuristic(256, buffer_size);
-ProcessSP process_sp = m_exe_ctx.GetProcessSP();
-ProcessMemoryIterator iterator(process_sp, low);
-
-for (size_t idx = 0; idx < buffer_size - 1; idx++) {
-  decltype(bad_char_heuristic)::size_type bcu_idx = buffer[idx];
-  bad_char_heuristic[bcu_idx] = buffer_size - idx - 1;
-}
-for (size_t s = 0; s <= (region_size - buffer_size);) {
-  int64_t j = buffer_size - 1;
-  while (j >= 0 && buffer[j] == iterator[s + j])
-j--;
-  if (j < 0)
-return low + s;
-  else
-s += bad_char_heuristic[iterator[s + buffer_size - 1]];
-}
-
-return LLDB_INVALID_ADDRESS;
-  }
-
   OptionGroupOptions m_option_group;
   

[Lldb-commits] [lldb] [nfc][lldb] Move FastSearch from CommandObjectMemoryFind to Process (PR #93688)

2024-05-29 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff bbca20f0b1ab7c6ea36a84e88a6abb07f94ca80b 
b6ac1147a441d774c8a5ea4c2de620b72be151e2 -- lldb/include/lldb/Target/Process.h 
lldb/source/Commands/CommandObjectMemory.cpp lldb/source/Target/Process.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index f293d1e784..eec337c15f 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -2682,7 +2682,7 @@ void PruneThreadPlans();
   ///
   /// \return The address where the pattern was found or LLDB_INVALID_ADDRESS 
if
   /// not found.
-  lldb::addr_t FindInMemory(lldb::addr_t low, lldb::addr_t high, 
+  lldb::addr_t FindInMemory(lldb::addr_t low, lldb::addr_t high,
 const uint8_t *buf, size_t size);
 
 protected:
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 2e0a96b07b..1e321f8bde 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -115,7 +115,7 @@ public:
 class ProcessMemoryIterator {
 public:
   ProcessMemoryIterator(Process , lldb::addr_t base)
-  : m_process(process), m_base_addr(base) { }
+  : m_process(process), m_base_addr(base) {}
 
   bool IsValid() { return m_is_valid; }
 
@@ -125,8 +125,7 @@ public:
 
 uint8_t retval = 0;
 Status error;
-if (0 ==
-m_process.ReadMemory(m_base_addr + offset, , 1, error)) {
+if (0 == m_process.ReadMemory(m_base_addr + offset, , 1, error)) {
   m_is_valid = false;
   return 0;
 }
@@ -134,10 +133,10 @@ public:
 return retval;
   }
 
-  private:
-Process _process;
-const lldb::addr_t m_base_addr;
-bool m_is_valid = true;
+private:
+  Process _process;
+  const lldb::addr_t m_base_addr;
+  bool m_is_valid = true;
 };
 
 static constexpr OptionEnumValueElement g_follow_fork_mode_values[] = {

``




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


[Lldb-commits] [lldb] [nfc][lldb] Move FastSearch from CommandObjectMemoryFind to Process (PR #93688)

2024-05-29 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Miro Bucko (mbucko)


Changes

Summary:
Moving CommandObjectMemoryFind::FastSearch() to Process::FindInMemory(). Plan 
to expose FindInMemory as public API in SBProcess.

Test Plan:
ninja check-lldb

Reviewers: clayborg

Subscribers:

Tasks:
lldb

Tags:

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


3 Files Affected:

- (modified) lldb/include/lldb/Target/Process.h (+22) 
- (modified) lldb/source/Commands/CommandObjectMemory.cpp (+2-59) 
- (modified) lldb/source/Target/Process.cpp (+55) 


``diff
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 637d34c29715c1..f293d1e78494f7 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -2663,6 +2663,28 @@ void PruneThreadPlans();
 return m_source_file_cache;
   }
 
+  /// Find a pattern within a memory region.
+  ///
+  /// This function searches for a pattern represented by the provided buffer
+  /// within the memory range specified by the low and high addresses. It uses
+  /// a bad character heuristic to optimize the search process.
+  ///
+  /// \param[in] low The starting address of the memory region to be searched.
+  /// (inclusive)
+  ///
+  /// \param[in] high The ending address of the memory region to be searched.
+  /// (exclusive)
+  ///
+  /// \param[in] buf A pointer to the buffer containing the pattern to be
+  /// searched.
+  ///
+  /// \param[in] buffer_size The size of the buffer in bytes.
+  ///
+  /// \return The address where the pattern was found or LLDB_INVALID_ADDRESS 
if
+  /// not found.
+  lldb::addr_t FindInMemory(lldb::addr_t low, lldb::addr_t high, 
+const uint8_t *buf, size_t size);
+
 protected:
   friend class Trace;
 
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp 
b/lldb/source/Commands/CommandObjectMemory.cpp
index b78a0492cca558..1c13484dede648 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -977,35 +977,6 @@ class CommandObjectMemoryFind : public CommandObjectParsed 
{
   Options *GetOptions() override { return _option_group; }
 
 protected:
-  class ProcessMemoryIterator {
-  public:
-ProcessMemoryIterator(ProcessSP process_sp, lldb::addr_t base)
-: m_process_sp(process_sp), m_base_addr(base) {
-  lldbassert(process_sp.get() != nullptr);
-}
-
-bool IsValid() { return m_is_valid; }
-
-uint8_t operator[](lldb::addr_t offset) {
-  if (!IsValid())
-return 0;
-
-  uint8_t retval = 0;
-  Status error;
-  if (0 ==
-  m_process_sp->ReadMemory(m_base_addr + offset, , 1, error)) {
-m_is_valid = false;
-return 0;
-  }
-
-  return retval;
-}
-
-  private:
-ProcessSP m_process_sp;
-lldb::addr_t m_base_addr;
-bool m_is_valid = true;
-  };
   void DoExecute(Args , CommandReturnObject ) override {
 // No need to check "process" for validity as eCommandRequiresProcess
 // ensures it is valid
@@ -1106,8 +1077,8 @@ class CommandObjectMemoryFind : public 
CommandObjectParsed {
 found_location = low_addr;
 bool ever_found = false;
 while (count) {
-  found_location = FastSearch(found_location, high_addr, buffer.GetBytes(),
-  buffer.GetByteSize());
+  found_location = process->FindInMemory(
+  found_location, high_addr, buffer.GetBytes(), buffer.GetByteSize());
   if (found_location == LLDB_INVALID_ADDRESS) {
 if (!ever_found) {
   result.AppendMessage("data not found within the range.\n");
@@ -1144,34 +1115,6 @@ class CommandObjectMemoryFind : public 
CommandObjectParsed {
 result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
   }
 
-  lldb::addr_t FastSearch(lldb::addr_t low, lldb::addr_t high, uint8_t *buffer,
-  size_t buffer_size) {
-const size_t region_size = high - low;
-
-if (region_size < buffer_size)
-  return LLDB_INVALID_ADDRESS;
-
-std::vector bad_char_heuristic(256, buffer_size);
-ProcessSP process_sp = m_exe_ctx.GetProcessSP();
-ProcessMemoryIterator iterator(process_sp, low);
-
-for (size_t idx = 0; idx < buffer_size - 1; idx++) {
-  decltype(bad_char_heuristic)::size_type bcu_idx = buffer[idx];
-  bad_char_heuristic[bcu_idx] = buffer_size - idx - 1;
-}
-for (size_t s = 0; s <= (region_size - buffer_size);) {
-  int64_t j = buffer_size - 1;
-  while (j >= 0 && buffer[j] == iterator[s + j])
-j--;
-  if (j < 0)
-return low + s;
-  else
-s += bad_char_heuristic[iterator[s + buffer_size - 1]];
-}
-
-return LLDB_INVALID_ADDRESS;
-  }
-
   OptionGroupOptions m_option_group;
   OptionGroupFindMemory m_memory_options;
   OptionGroupMemoryTag m_memory_tag_options;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index 

[Lldb-commits] [lldb] [nfc][lldb] Move FastSearch from CommandObjectMemoryFind to Process (PR #93688)

2024-05-29 Thread Miro Bucko via lldb-commits

https://github.com/mbucko created 
https://github.com/llvm/llvm-project/pull/93688

Summary:
Moving CommandObjectMemoryFind::FastSearch() to Process::FindInMemory(). Plan 
to expose FindInMemory as public API in SBProcess.

Test Plan:
ninja check-lldb

Reviewers: clayborg

Subscribers:

Tasks:
lldb

Tags:

>From b6ac1147a441d774c8a5ea4c2de620b72be151e2 Mon Sep 17 00:00:00 2001
From: Miro Bucko 
Date: Wed, 29 May 2024 06:38:22 -0700
Subject: [PATCH] [nfc][lldb] Move FastSearch from CommandObjectMemoryFind to
 Process

Summary:
Moving CommandObjectMemoryFind::FastSearch() to Process::FindInMemory().
Plan to expose FindInMemory as public API in SBProcess.

Test Plan:
ninja check-lldb

Reviewers:

Subscribers:

Tasks:
lldb

Tags:
---
 lldb/include/lldb/Target/Process.h   | 22 +++
 lldb/source/Commands/CommandObjectMemory.cpp | 61 +---
 lldb/source/Target/Process.cpp   | 55 ++
 3 files changed, 79 insertions(+), 59 deletions(-)

diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 637d34c29715c1..f293d1e78494f7 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -2663,6 +2663,28 @@ void PruneThreadPlans();
 return m_source_file_cache;
   }
 
+  /// Find a pattern within a memory region.
+  ///
+  /// This function searches for a pattern represented by the provided buffer
+  /// within the memory range specified by the low and high addresses. It uses
+  /// a bad character heuristic to optimize the search process.
+  ///
+  /// \param[in] low The starting address of the memory region to be searched.
+  /// (inclusive)
+  ///
+  /// \param[in] high The ending address of the memory region to be searched.
+  /// (exclusive)
+  ///
+  /// \param[in] buf A pointer to the buffer containing the pattern to be
+  /// searched.
+  ///
+  /// \param[in] buffer_size The size of the buffer in bytes.
+  ///
+  /// \return The address where the pattern was found or LLDB_INVALID_ADDRESS 
if
+  /// not found.
+  lldb::addr_t FindInMemory(lldb::addr_t low, lldb::addr_t high, 
+const uint8_t *buf, size_t size);
+
 protected:
   friend class Trace;
 
diff --git a/lldb/source/Commands/CommandObjectMemory.cpp 
b/lldb/source/Commands/CommandObjectMemory.cpp
index b78a0492cca558..1c13484dede648 100644
--- a/lldb/source/Commands/CommandObjectMemory.cpp
+++ b/lldb/source/Commands/CommandObjectMemory.cpp
@@ -977,35 +977,6 @@ class CommandObjectMemoryFind : public CommandObjectParsed 
{
   Options *GetOptions() override { return _option_group; }
 
 protected:
-  class ProcessMemoryIterator {
-  public:
-ProcessMemoryIterator(ProcessSP process_sp, lldb::addr_t base)
-: m_process_sp(process_sp), m_base_addr(base) {
-  lldbassert(process_sp.get() != nullptr);
-}
-
-bool IsValid() { return m_is_valid; }
-
-uint8_t operator[](lldb::addr_t offset) {
-  if (!IsValid())
-return 0;
-
-  uint8_t retval = 0;
-  Status error;
-  if (0 ==
-  m_process_sp->ReadMemory(m_base_addr + offset, , 1, error)) {
-m_is_valid = false;
-return 0;
-  }
-
-  return retval;
-}
-
-  private:
-ProcessSP m_process_sp;
-lldb::addr_t m_base_addr;
-bool m_is_valid = true;
-  };
   void DoExecute(Args , CommandReturnObject ) override {
 // No need to check "process" for validity as eCommandRequiresProcess
 // ensures it is valid
@@ -1106,8 +1077,8 @@ class CommandObjectMemoryFind : public 
CommandObjectParsed {
 found_location = low_addr;
 bool ever_found = false;
 while (count) {
-  found_location = FastSearch(found_location, high_addr, buffer.GetBytes(),
-  buffer.GetByteSize());
+  found_location = process->FindInMemory(
+  found_location, high_addr, buffer.GetBytes(), buffer.GetByteSize());
   if (found_location == LLDB_INVALID_ADDRESS) {
 if (!ever_found) {
   result.AppendMessage("data not found within the range.\n");
@@ -1144,34 +1115,6 @@ class CommandObjectMemoryFind : public 
CommandObjectParsed {
 result.SetStatus(lldb::eReturnStatusSuccessFinishResult);
   }
 
-  lldb::addr_t FastSearch(lldb::addr_t low, lldb::addr_t high, uint8_t *buffer,
-  size_t buffer_size) {
-const size_t region_size = high - low;
-
-if (region_size < buffer_size)
-  return LLDB_INVALID_ADDRESS;
-
-std::vector bad_char_heuristic(256, buffer_size);
-ProcessSP process_sp = m_exe_ctx.GetProcessSP();
-ProcessMemoryIterator iterator(process_sp, low);
-
-for (size_t idx = 0; idx < buffer_size - 1; idx++) {
-  decltype(bad_char_heuristic)::size_type bcu_idx = buffer[idx];
-  bad_char_heuristic[bcu_idx] = buffer_size - idx - 1;
-}
-for (size_t s = 0; s <= (region_size - buffer_size);) {
-  int64_t j = buffer_size - 1;
-  while (j >= 0 && buffer[j] == iterator[s + j])
-  

[Lldb-commits] [lldb] [lldb/DWARF] Follow DW_AT_signature when computing type contexts (PR #93675)

2024-05-29 Thread Michael Buch via lldb-commits

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


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


[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

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

labath wrote:

> @labath baseline for just attaching is approximately `3 s` for LLDB and `2.5 
> s`. Baselines for attaching _and_ stopping at the breakpoint are in the 
> `break only` rows of the table.

Thanks. I think this resolves my concerns about this patch. If we do find a 
particularly expensive/hot place reporting progress events, we can always 
remove it.

> Now that we don't search for the definition DIE when initially parsing a DIE, 
> we could probably move this progress report to `FindDefinitionTypeForDIE`, 
> which seems to be the most expensive part of the `DWARFASTParser`

SGTM

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


[Lldb-commits] [lldb] [lldb/DWARF] Follow DW_AT_signature when computing type contexts (PR #93675)

2024-05-29 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

This is necessary to correctly resolve the context within types, as the name of 
the type is only present in the type unit.

(The DWARFYAML enthusiasm didn't last long, as it does not support type units. 
It can still be used for testing a lot of other things though.)

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


3 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp (+12) 
- (modified) lldb/test/Shell/SymbolFile/DWARF/x86/Inputs/debug-types-basic.cpp 
(+9) 
- (modified) lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-basic.test (+8-1) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index 03e289bbf3300..7cf92adc6ef57 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -16,6 +16,7 @@
 #include "lldb/Symbol/Type.h"
 
 #include "llvm/ADT/iterator.h"
+#include "llvm/BinaryFormat/Dwarf.h"
 
 using namespace lldb_private;
 using namespace lldb_private::dwarf;
@@ -390,6 +391,11 @@ static void GetDeclContextImpl(DWARFDIE die,
   die = spec;
   continue;
 }
+// To find the name of a type in a type unit, we must follow the signature.
+if (DWARFDIE spec = die.GetReferencedDIE(DW_AT_signature)) {
+  die = spec;
+  continue;
+}
 
 // Add this DIE's contribution at the end of the chain.
 auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
@@ -444,6 +450,12 @@ static void GetTypeLookupContextImpl(DWARFDIE die,
  std::vector ) {
   // Stop if we hit a cycle.
   while (die && seen.insert(die.GetID()).second) {
+// To find the name of a type in a type unit, we must follow the signature.
+if (DWARFDIE spec = die.GetReferencedDIE(DW_AT_signature)) {
+  die = spec;
+  continue;
+}
+
 // If there is no name, then there is no need to look anything up for this
 // DIE.
 const char *name = die.GetName();
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/Inputs/debug-types-basic.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/Inputs/debug-types-basic.cpp
index defa8ba5c69e7..24fa05505fd38 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/Inputs/debug-types-basic.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/Inputs/debug-types-basic.cpp
@@ -10,6 +10,15 @@ struct A {
   EC ec;
 };
 
+struct Outer {
+  int i;
+  struct Inner {
+long l;
+  };
+};
+
 extern constexpr A a{42, 47l, 4.2f, 4.7, e1, EC::e3};
 extern constexpr E e(e2);
 extern constexpr EC ec(EC::e2);
+extern constexpr Outer outer{47};
+extern constexpr Outer::Inner outer_inner{42l};
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-basic.test 
b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-basic.test
index dc8005f73930e..47a6ecf39033d 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-basic.test
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-basic.test
@@ -51,6 +51,12 @@ type lookup EC
 # CHECK-NEXT:   e3
 # CHECK-NEXT: }
 
+type lookup Outer::Inner
+# CHECK-LABEL: type lookup Outer::Inner
+# CHECK:  struct Inner {
+# CHECK-NEXT:   long l;
+# CHECK-NEXT: }
+
 expression (E) 1
 # CHECK-LABEL: expression (E) 1
 # CHECK: (E) $0 = e2
@@ -59,8 +65,9 @@ expression (EC) 1
 # CHECK-LABEL: expression (EC) 1
 # CHECK: (EC) $1 = e2
 
-target variable a e ec
+target variable a e ec outer_inner
 # CHECK-LABEL: target variable a e ec
 # CHECK: (const A) a = (i = 42, l = 47, f = 4.{{[12].*}}, d = 4.{{[67].*}}, e 
= e1, ec = e3)
 # CHECK: (const E) e = e2
 # CHECK: (const EC) ec = e2
+# CHECK: (const Outer::Inner) outer_inner = (l = 42)

``




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


[Lldb-commits] [lldb] [lldb/DWARF] Follow DW_AT_signature when computing type contexts (PR #93675)

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

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

This is necessary to correctly resolve the context within types, as the name of 
the type is only present in the type unit.

(The DWARFYAML enthusiasm didn't last long, as it does not support type units. 
It can still be used for testing a lot of other things though.)

>From 24ad88466121da79dc448a9b8fcf65bb1800d14b Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Fri, 24 May 2024 10:41:06 +
Subject: [PATCH] [lldb/DWARF] Follow DW_AT_signature when computing type
 contexts

This is necessary to correctly resolve the context within types, as the
name of the type is only present in the type unit.
---
 lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp| 12 
 .../DWARF/x86/Inputs/debug-types-basic.cpp   |  9 +
 .../SymbolFile/DWARF/x86/debug-types-basic.test  |  9 -
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index 03e289bbf3300..7cf92adc6ef57 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -16,6 +16,7 @@
 #include "lldb/Symbol/Type.h"
 
 #include "llvm/ADT/iterator.h"
+#include "llvm/BinaryFormat/Dwarf.h"
 
 using namespace lldb_private;
 using namespace lldb_private::dwarf;
@@ -390,6 +391,11 @@ static void GetDeclContextImpl(DWARFDIE die,
   die = spec;
   continue;
 }
+// To find the name of a type in a type unit, we must follow the signature.
+if (DWARFDIE spec = die.GetReferencedDIE(DW_AT_signature)) {
+  die = spec;
+  continue;
+}
 
 // Add this DIE's contribution at the end of the chain.
 auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
@@ -444,6 +450,12 @@ static void GetTypeLookupContextImpl(DWARFDIE die,
  std::vector ) {
   // Stop if we hit a cycle.
   while (die && seen.insert(die.GetID()).second) {
+// To find the name of a type in a type unit, we must follow the signature.
+if (DWARFDIE spec = die.GetReferencedDIE(DW_AT_signature)) {
+  die = spec;
+  continue;
+}
+
 // If there is no name, then there is no need to look anything up for this
 // DIE.
 const char *name = die.GetName();
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/Inputs/debug-types-basic.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/Inputs/debug-types-basic.cpp
index defa8ba5c69e7..24fa05505fd38 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/Inputs/debug-types-basic.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/Inputs/debug-types-basic.cpp
@@ -10,6 +10,15 @@ struct A {
   EC ec;
 };
 
+struct Outer {
+  int i;
+  struct Inner {
+long l;
+  };
+};
+
 extern constexpr A a{42, 47l, 4.2f, 4.7, e1, EC::e3};
 extern constexpr E e(e2);
 extern constexpr EC ec(EC::e2);
+extern constexpr Outer outer{47};
+extern constexpr Outer::Inner outer_inner{42l};
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-basic.test 
b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-basic.test
index dc8005f73930e..47a6ecf39033d 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-basic.test
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/debug-types-basic.test
@@ -51,6 +51,12 @@ type lookup EC
 # CHECK-NEXT:   e3
 # CHECK-NEXT: }
 
+type lookup Outer::Inner
+# CHECK-LABEL: type lookup Outer::Inner
+# CHECK:  struct Inner {
+# CHECK-NEXT:   long l;
+# CHECK-NEXT: }
+
 expression (E) 1
 # CHECK-LABEL: expression (E) 1
 # CHECK: (E) $0 = e2
@@ -59,8 +65,9 @@ expression (EC) 1
 # CHECK-LABEL: expression (EC) 1
 # CHECK: (EC) $1 = e2
 
-target variable a e ec
+target variable a e ec outer_inner
 # CHECK-LABEL: target variable a e ec
 # CHECK: (const A) a = (i = 42, l = 47, f = 4.{{[12].*}}, d = 4.{{[67].*}}, e 
= e1, ec = e3)
 # CHECK: (const E) e = e2
 # CHECK: (const EC) ec = e2
+# CHECK: (const Outer::Inner) outer_inner = (l = 42)

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


[Lldb-commits] [lldb] [lldb/DWARF] Refactor DWARFDIE::Get{Decl, TypeLookup}Context (PR #93291)

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

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


[Lldb-commits] [lldb] 8e12904 - [lldb/DWARF] Refactor DWARFDIE::Get{Decl, TypeLookup}Context (#93291)

2024-05-29 Thread via lldb-commits

Author: Pavel Labath
Date: 2024-05-29T14:19:49+02:00
New Revision: 8e1290432adf33a7aeca65a53d1faa7577ed0e66

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

LOG: [lldb/DWARF] Refactor DWARFDIE::Get{Decl,TypeLookup}Context (#93291)

After a bug (the bug is that the functions don't handle DW_AT_signature,
aka type units) led me to one of these similar-but-different functions,
I started to realize that most of the differences between these two
functions are actually bugs.

As a first step towards merging them, this patch rewrites both of them
to follow the same pattern, while preserving all of their differences.
The main change is that GetTypeLookupContext now also uses a `seen` list
to avoid reference loops (currently that's not necessary because the
function strictly follows parent links, but that will change with
DW_AT_signatures).

I've also optimized both functions to avoid recursion by starting contruction
with the deepest scope first (and then reversing it).

Added: 


Modified: 
lldb/include/lldb/Symbol/Type.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
lldb/source/Symbol/Type.cpp
lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index 7aa0852676e46..c6f30cde81867 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -62,6 +62,8 @@ struct CompilerContext {
   CompilerContextKind kind;
   ConstString name;
 };
+llvm::raw_ostream <<(llvm::raw_ostream ,
+  const CompilerContext );
 
 /// Match \p context_chain against \p pattern, which may contain "Any"
 /// kinds. The \p context_chain should *not* contain any "Any" kinds.

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index 4884374ef9472..03e289bbf3300 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -13,6 +13,7 @@
 #include "DWARFDebugInfoEntry.h"
 #include "DWARFDeclContext.h"
 #include "DWARFUnit.h"
+#include "lldb/Symbol/Type.h"
 
 #include "llvm/ADT/iterator.h"
 
@@ -379,108 +380,118 @@ std::vector DWARFDIE::GetDeclContextDIEs() 
const {
   return result;
 }
 
-static std::vector
-GetDeclContextImpl(llvm::SmallSet , DWARFDIE die) {
-  std::vector context;
+static void GetDeclContextImpl(DWARFDIE die,
+   llvm::SmallSet ,
+   std::vector ) {
   // Stop if we hit a cycle.
-  if (!die || !seen.insert(die.GetID()).second)
-return context;
-
-  // Handle outline member function DIEs by following the specification.
-  if (DWARFDIE spec = die.GetReferencedDIE(DW_AT_specification))
-return GetDeclContextImpl(seen, spec);
-
-  // Get the parent context chain.
-  context = GetDeclContextImpl(seen, die.GetParent());
+  while (die && seen.insert(die.GetID()).second) {
+// Handle outline member function DIEs by following the specification.
+if (DWARFDIE spec = die.GetReferencedDIE(DW_AT_specification)) {
+  die = spec;
+  continue;
+}
 
-  // Add this DIE's contribution at the end of the chain.
-  auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
-context.push_back({kind, ConstString(name)});
-  };
-  switch (die.Tag()) {
-  case DW_TAG_module:
-push_ctx(CompilerContextKind::Module, die.GetName());
-break;
-  case DW_TAG_namespace:
-push_ctx(CompilerContextKind::Namespace, die.GetName());
-break;
-  case DW_TAG_structure_type:
-push_ctx(CompilerContextKind::Struct, die.GetName());
-break;
-  case DW_TAG_union_type:
-push_ctx(CompilerContextKind::Union, die.GetName());
-break;
-  case DW_TAG_class_type:
-push_ctx(CompilerContextKind::Class, die.GetName());
-break;
-  case DW_TAG_enumeration_type:
-push_ctx(CompilerContextKind::Enum, die.GetName());
-break;
-  case DW_TAG_subprogram:
-push_ctx(CompilerContextKind::Function, die.GetName());
-break;
-  case DW_TAG_variable:
-push_ctx(CompilerContextKind::Variable, die.GetPubname());
-break;
-  case DW_TAG_typedef:
-push_ctx(CompilerContextKind::Typedef, die.GetName());
-break;
-  default:
-break;
+// Add this DIE's contribution at the end of the chain.
+auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
+  context.push_back({kind, ConstString(name)});
+};
+switch (die.Tag()) {
+case DW_TAG_module:
+  push_ctx(CompilerContextKind::Module, die.GetName());
+  break;
+case DW_TAG_namespace:
+  push_ctx(CompilerContextKind::Namespace, die.GetName());
+  break;
+case DW_TAG_structure_type:
+  push_ctx(CompilerContextKind::Struct, 

[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-29 Thread Michael Buch via lldb-commits

Michael137 wrote:

Now that we don't search for the definition DIE when initially parsing a DIE, 
we could probably move this progress report to when we look for 
`FindDefinitionTypeForDIE`, which seems to be the most expensive part of the 
`DWARFASTParser`

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


[Lldb-commits] [lldb] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-29 Thread Michael Buch via lldb-commits

Michael137 wrote:

@labath baseline for just attaching is approximately `3 s` for LLDB and `2.5 
s`. Baselines for attaching *and* stopping at the breakpoint are in the `break 
only` rows of the table.

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


[Lldb-commits] [lldb] [lldb/DWARF] Refactor DWARFDIE::Get{Decl, TypeLookup}Context (PR #93291)

2024-05-29 Thread Michael Buch via lldb-commits

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

nice! tests also LGTM

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


[Lldb-commits] [lldb] [lldb/DWARF] Refactor DWARFDIE::Get{Decl, TypeLookup}Context (PR #93291)

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

labath wrote:

Good idea. I've added one quick test. I'll add more as I work on these 
functions further. PTAL

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


[Lldb-commits] [lldb] [lldb/DWARF] Refactor DWARFDIE::Get{Decl, TypeLookup}Context (PR #93291)

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

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/93291

>From 8463c2433609216499fe5d04c3397a3113071a49 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Fri, 24 May 2024 10:17:40 +
Subject: [PATCH 1/2] [lldb/DWARF] Refactor
 DWARFDIE::Get{Decl,TypeLookup}Context

After a bug (the bug is that the functions don't handle DW_AT_signature,
aka type units) led me to one of these similar-but-different functions,
I started to realize that most of the differences between these two
functions are actually bugs.

As a first step towards merging them, this patch rewrites both of them
to follow the same pattern, while preserving all of their differences.
The main change is that GetTypeLookupContext now also uses a `seen` list
to avoid reference loops (currently that's not necessary because the
function strictly follows parent links, but that will change with
DW_AT_signatures).

I've also optimized both functions to avoid recursion by contructing
starting with the deepest scope first (and then reversing it).
---
 .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp | 197 +-
 1 file changed, 104 insertions(+), 93 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index 4884374ef9472..03e289bbf3300 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -13,6 +13,7 @@
 #include "DWARFDebugInfoEntry.h"
 #include "DWARFDeclContext.h"
 #include "DWARFUnit.h"
+#include "lldb/Symbol/Type.h"
 
 #include "llvm/ADT/iterator.h"
 
@@ -379,108 +380,118 @@ std::vector DWARFDIE::GetDeclContextDIEs() 
const {
   return result;
 }
 
-static std::vector
-GetDeclContextImpl(llvm::SmallSet , DWARFDIE die) {
-  std::vector context;
+static void GetDeclContextImpl(DWARFDIE die,
+   llvm::SmallSet ,
+   std::vector ) {
   // Stop if we hit a cycle.
-  if (!die || !seen.insert(die.GetID()).second)
-return context;
-
-  // Handle outline member function DIEs by following the specification.
-  if (DWARFDIE spec = die.GetReferencedDIE(DW_AT_specification))
-return GetDeclContextImpl(seen, spec);
-
-  // Get the parent context chain.
-  context = GetDeclContextImpl(seen, die.GetParent());
+  while (die && seen.insert(die.GetID()).second) {
+// Handle outline member function DIEs by following the specification.
+if (DWARFDIE spec = die.GetReferencedDIE(DW_AT_specification)) {
+  die = spec;
+  continue;
+}
 
-  // Add this DIE's contribution at the end of the chain.
-  auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
-context.push_back({kind, ConstString(name)});
-  };
-  switch (die.Tag()) {
-  case DW_TAG_module:
-push_ctx(CompilerContextKind::Module, die.GetName());
-break;
-  case DW_TAG_namespace:
-push_ctx(CompilerContextKind::Namespace, die.GetName());
-break;
-  case DW_TAG_structure_type:
-push_ctx(CompilerContextKind::Struct, die.GetName());
-break;
-  case DW_TAG_union_type:
-push_ctx(CompilerContextKind::Union, die.GetName());
-break;
-  case DW_TAG_class_type:
-push_ctx(CompilerContextKind::Class, die.GetName());
-break;
-  case DW_TAG_enumeration_type:
-push_ctx(CompilerContextKind::Enum, die.GetName());
-break;
-  case DW_TAG_subprogram:
-push_ctx(CompilerContextKind::Function, die.GetName());
-break;
-  case DW_TAG_variable:
-push_ctx(CompilerContextKind::Variable, die.GetPubname());
-break;
-  case DW_TAG_typedef:
-push_ctx(CompilerContextKind::Typedef, die.GetName());
-break;
-  default:
-break;
+// Add this DIE's contribution at the end of the chain.
+auto push_ctx = [&](CompilerContextKind kind, llvm::StringRef name) {
+  context.push_back({kind, ConstString(name)});
+};
+switch (die.Tag()) {
+case DW_TAG_module:
+  push_ctx(CompilerContextKind::Module, die.GetName());
+  break;
+case DW_TAG_namespace:
+  push_ctx(CompilerContextKind::Namespace, die.GetName());
+  break;
+case DW_TAG_structure_type:
+  push_ctx(CompilerContextKind::Struct, die.GetName());
+  break;
+case DW_TAG_union_type:
+  push_ctx(CompilerContextKind::Union, die.GetName());
+  break;
+case DW_TAG_class_type:
+  push_ctx(CompilerContextKind::Class, die.GetName());
+  break;
+case DW_TAG_enumeration_type:
+  push_ctx(CompilerContextKind::Enum, die.GetName());
+  break;
+case DW_TAG_subprogram:
+  push_ctx(CompilerContextKind::Function, die.GetName());
+  break;
+case DW_TAG_variable:
+  push_ctx(CompilerContextKind::Variable, die.GetPubname());
+  break;
+case DW_TAG_typedef:
+  push_ctx(CompilerContextKind::Typedef, die.GetName());
+  break;
+default:
+  break;
+}
+// Now process the parent.
+die = die.GetParent();
   }
-  return context;
 }
 

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

2024-05-29 Thread David Spickett via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] 23a09b9 - [lldb][Test] Remove some xfails for AArch64 Linux

2024-05-29 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2024-05-29T10:28:10Z
New Revision: 23a09b99313edb67d267a974be6cebfdfd97c7c8

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

LOG: [lldb][Test] Remove some xfails for AArch64 Linux

PR #92245 fixed these tests on Linux. They likely work on FreeBSD too
but leaving the xfail for that so it can be confirmed later.

Also updated a bugzilla link to one that redirects to Github issues.

Relates to issues #43398 and #48751.

Added: 


Modified: 
lldb/test/API/commands/expression/fixits/TestFixIts.py

lldb/test/API/commands/expression/static-initializers/TestStaticInitializers.py

Removed: 




diff  --git a/lldb/test/API/commands/expression/fixits/TestFixIts.py 
b/lldb/test/API/commands/expression/fixits/TestFixIts.py
index bc53b72fe611b..1b22ed1c0077c 100644
--- a/lldb/test/API/commands/expression/fixits/TestFixIts.py
+++ b/lldb/test/API/commands/expression/fixits/TestFixIts.py
@@ -106,9 +106,8 @@ def test_with_target_error_applies_fixit(self):
 )
 self.assertIn("null_pointer->first", ret_val.GetError())
 
-# The final function call runs into SIGILL on aarch64-linux.
 @expectedFailureAll(
-archs=["aarch64"], oslist=["freebsd", "linux"], 
bugnumber="llvm.org/pr49407"
+archs=["aarch64"], oslist=["freebsd"], bugnumber="llvm.org/pr49407"
 )
 def test_with_multiple_retries(self):
 """Test calling expressions with errors that can be fixed by the 
FixIts."""

diff  --git 
a/lldb/test/API/commands/expression/static-initializers/TestStaticInitializers.py
 
b/lldb/test/API/commands/expression/static-initializers/TestStaticInitializers.py
index 5fc37ac6a5818..ea3aa6a4608c4 100644
--- 
a/lldb/test/API/commands/expression/static-initializers/TestStaticInitializers.py
+++ 
b/lldb/test/API/commands/expression/static-initializers/TestStaticInitializers.py
@@ -7,8 +7,8 @@
 class StaticInitializers(TestBase):
 @expectedFailureAll(
 archs="aarch64",
-oslist=["freebsd", "linux"],
-bugnumber="https://bugs.llvm.org/show_bug.cgi?id=44053;,
+oslist=["freebsd"],
+bugnumber="llvm.org/pr44053",
 )
 def test(self):
 """Test a static initializer."""



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


[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-29 Thread Alexey Merzlyakov via lldb-commits


@@ -0,0 +1,84 @@
+//===-- RegisterContextPOSIXCore_riscv64.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RegisterContextPOSIXCore_riscv64.h"
+
+#include "lldb/Utility/DataBufferHeap.h"
+
+using namespace lldb_private;
+
+std::unique_ptr
+RegisterContextCorePOSIX_riscv64::Create(
+lldb_private::Thread , const lldb_private::ArchSpec ,
+const lldb_private::DataExtractor ,
+llvm::ArrayRef notes) {
+  Flags flags = 0;
+
+  auto register_info_up =
+  std::make_unique(arch, flags);
+  return std::unique_ptr(
+  new RegisterContextCorePOSIX_riscv64(thread, std::move(register_info_up),
+   gpregset, notes));
+}
+
+RegisterContextCorePOSIX_riscv64::RegisterContextCorePOSIX_riscv64(
+Thread , std::unique_ptr register_info,
+const DataExtractor , llvm::ArrayRef notes)
+: RegisterContextPOSIX_riscv64(thread, std::move(register_info)) {
+
+  m_gpr_buffer = std::make_shared(gpregset.GetDataStart(),
+  gpregset.GetByteSize());
+  m_gpr.SetData(m_gpr_buffer);
+  m_gpr.SetByteOrder(gpregset.GetByteOrder());
+
+  ArchSpec arch = m_register_info_up->GetTargetArchitecture();
+  DataExtractor fpregset = getRegset(notes, arch.GetTriple(), FPR_Desc);
+  m_fpr_buffer = std::make_shared(fpregset.GetDataStart(),
+  fpregset.GetByteSize());
+  m_fpr.SetData(m_fpr_buffer);
+  m_fpr.SetByteOrder(fpregset.GetByteOrder());
+}
+
+RegisterContextCorePOSIX_riscv64::~RegisterContextCorePOSIX_riscv64() = 
default;
+
+bool RegisterContextCorePOSIX_riscv64::ReadGPR() { return true; }
+
+bool RegisterContextCorePOSIX_riscv64::ReadFPR() { return true; }
+
+bool RegisterContextCorePOSIX_riscv64::WriteGPR() {
+  assert(0);

AlexeyMerzlyakov wrote:

Done in latest 
[commit](https://github.com/llvm/llvm-project/pull/93297/commits/7239f6293ee088a7cde8fa2e6feee00aedf7ac9a#diff-e10987e6f6d77043ea40e6564367e979569651da252148e82ce3e99ab4f44ae3R57).
 If I understood well, the work with coredumps is not implied register changing 
(all core plugins for other architectures are also having `assert(0)` 
construction in their register writing routines), so these methods are not 
going to be implemented in future. I've changed the assertion message to 
`Writing registers is not allowed for core dumps`. Please correct me, if I 
wrong.

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


[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-29 Thread Alexey Merzlyakov via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-29 Thread Alexey Merzlyakov via lldb-commits


@@ -0,0 +1,84 @@
+//===-- RegisterContextPOSIXCore_riscv64.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RegisterContextPOSIXCore_riscv64.h"
+
+#include "lldb/Utility/DataBufferHeap.h"
+
+using namespace lldb_private;
+
+std::unique_ptr
+RegisterContextCorePOSIX_riscv64::Create(
+lldb_private::Thread , const lldb_private::ArchSpec ,
+const lldb_private::DataExtractor ,
+llvm::ArrayRef notes) {
+  Flags flags = 0;
+
+  auto register_info_up =
+  std::make_unique(arch, flags);
+  return std::unique_ptr(
+  new RegisterContextCorePOSIX_riscv64(thread, std::move(register_info_up),
+   gpregset, notes));
+}
+
+RegisterContextCorePOSIX_riscv64::RegisterContextCorePOSIX_riscv64(
+Thread , std::unique_ptr register_info,
+const DataExtractor , llvm::ArrayRef notes)
+: RegisterContextPOSIX_riscv64(thread, std::move(register_info)) {
+
+  m_gpr_buffer = std::make_shared(gpregset.GetDataStart(),
+  gpregset.GetByteSize());
+  m_gpr.SetData(m_gpr_buffer);
+  m_gpr.SetByteOrder(gpregset.GetByteOrder());
+
+  ArchSpec arch = m_register_info_up->GetTargetArchitecture();
+  DataExtractor fpregset = getRegset(notes, arch.GetTriple(), FPR_Desc);
+  m_fpr_buffer = std::make_shared(fpregset.GetDataStart(),

AlexeyMerzlyakov wrote:

Yes, this is good point, since some architectures (like RV64IMAC) might not 
contain FP-registers at all.

However, it seems that in current state of implementation of RegisterInfo 
RISC-V plugin FP registers are always  enabled as GP ones. For example, 
[here](https://github.com/llvm/llvm-project/blob/78cc9cbba23fd1783a9b233ae745f126ece56cc7/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.cpp#L56)
 and 
[here](https://github.com/llvm/llvm-project/blob/78cc9cbba23fd1783a9b233ae745f126ece56cc7/lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.cpp#L123-L125).
 If we will just add the check in `RegisterContextCorePOSIX_riscv64()` 
contstructor / `Create()` routine, it won't be enough: LLDB will fail in 
run-time when try to iterate all the registers and will get wrong number from 
RegisterInfo plugin. The Info plugin is also should be re-worked itself, to 
have FP optionally enabled if `lldb_private::getRegset()` will confirm it.

As it seems to me and if you don't mind, I'd like to move this work to separate 
PR ticket, as it related more to RegisterInfo RISC-V plugin re-work rather than 
coredumps. I have some initial patch on it, but I'd like to test it well before 
having the final solution.

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


[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-29 Thread David Spickett via lldb-commits

DavidSpickett wrote:

The tests were hitting a deadlock trying to kill the test process in async 
debug mode. So I've just changed it to sync mode, as I didn't see any reason to 
be async here.

It's a symptom of something greater I expect but I don't have time to dig into 
it at the moment.

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


[Lldb-commits] [lldb] 971f1aa - [lldb][Test][Windows] Fix flaky address range API tests

2024-05-29 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2024-05-29T10:07:47Z
New Revision: 971f1aaad3ca3680bfbab76212f498ca15b280a2

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

LOG: [lldb][Test][Windows] Fix flaky address range API tests

The new tests added in #92014 have been flaky on Linaro's
Windows on Arm bot. They appear to be hitting a deadlock trying
to clean up the test process.

This only happens in async mode and I don't see why this test
case needs async mode, so the simple workaround is to stick to
sync mode.

Added: 


Modified: 
lldb/test/API/python_api/address_range/TestAddressRange.py

Removed: 




diff  --git a/lldb/test/API/python_api/address_range/TestAddressRange.py 
b/lldb/test/API/python_api/address_range/TestAddressRange.py
index 8c27558af4752..65221e3f1b0e9 100644
--- a/lldb/test/API/python_api/address_range/TestAddressRange.py
+++ b/lldb/test/API/python_api/address_range/TestAddressRange.py
@@ -15,8 +15,6 @@ def setUp(self):
 self.build()
 exe = self.getBuildArtifact("a.out")
 
-self.dbg.SetAsync(True)
-
 self.target = self.dbg.CreateTarget(exe)
 self.assertTrue(self.target, VALID_TARGET)
 self.launch_info = self.target.GetLaunchInfo()



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


[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-29 Thread Alexey Merzlyakov via lldb-commits


@@ -0,0 +1,84 @@
+//===-- RegisterContextPOSIXCore_riscv64.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RegisterContextPOSIXCore_riscv64.h"
+
+#include "lldb/Utility/DataBufferHeap.h"
+
+using namespace lldb_private;

AlexeyMerzlyakov wrote:

Removed all unnecessary `lldb_private::`from cpp-file in latest 
[commit](https://github.com/llvm/llvm-project/pull/93297/commits/7239f6293ee088a7cde8fa2e6feee00aedf7ac9a#)

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


[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-29 Thread Alexey Merzlyakov via lldb-commits


@@ -0,0 +1,84 @@
+//===-- RegisterContextPOSIXCore_riscv64.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RegisterContextPOSIXCore_riscv64.h"
+
+#include "lldb/Utility/DataBufferHeap.h"
+
+using namespace lldb_private;
+
+std::unique_ptr
+RegisterContextCorePOSIX_riscv64::Create(
+lldb_private::Thread , const lldb_private::ArchSpec ,
+const lldb_private::DataExtractor ,
+llvm::ArrayRef notes) {
+  Flags flags = 0;
+
+  auto register_info_up =
+  std::make_unique(arch, flags);
+  return std::unique_ptr(

AlexeyMerzlyakov wrote:

Done in latest 
[commit](https://github.com/llvm/llvm-project/pull/93297/commits/7239f6293ee088a7cde8fa2e6feee00aedf7ac9a#)

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


[Lldb-commits] [lldb] [lldb] Add RegisterContextPOSIXCore for RISC-V 64 (PR #93297)

2024-05-29 Thread Alexey Merzlyakov via lldb-commits

https://github.com/AlexeyMerzlyakov updated 
https://github.com/llvm/llvm-project/pull/93297

>From d30c3b7017bd9f4b9f442ee728d7e3d7847c60cf Mon Sep 17 00:00:00 2001
From: Alexey Merzlyakov 
Date: Fri, 24 May 2024 11:54:16 +0300
Subject: [PATCH 1/2] Add RegisterContextPOSIXCore for RISC-V 64

Fix GetRegisterSetCount() method name misprint for RegisterContextPOSIX_riscv64
---
 .../Utility/RegisterContextPOSIX_riscv64.cpp  |  2 +-
 .../Plugins/Process/elf-core/CMakeLists.txt   |  1 +
 .../RegisterContextPOSIXCore_riscv64.cpp  | 84 +++
 .../RegisterContextPOSIXCore_riscv64.h| 60 +
 .../Process/elf-core/ThreadElfCore.cpp|  8 +-
 5 files changed, 153 insertions(+), 2 deletions(-)
 create mode 100644 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp
 create mode 100644 
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.h

diff --git 
a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp 
b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp
index 1834a94dc0260..035ce00e11626 100644
--- a/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp
+++ b/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_riscv64.cpp
@@ -58,7 +58,7 @@ RegisterContextPOSIX_riscv64::GetRegisterInfoAtIndex(size_t 
reg) {
 }
 
 size_t RegisterContextPOSIX_riscv64::GetRegisterSetCount() {
-  return m_register_info_up->GetRegisterCount();
+  return m_register_info_up->GetRegisterSetCount();
 }
 
 const lldb_private::RegisterSet *
diff --git a/lldb/source/Plugins/Process/elf-core/CMakeLists.txt 
b/lldb/source/Plugins/Process/elf-core/CMakeLists.txt
index 8ddc671e3ae66..72925c835b5c8 100644
--- a/lldb/source/Plugins/Process/elf-core/CMakeLists.txt
+++ b/lldb/source/Plugins/Process/elf-core/CMakeLists.txt
@@ -9,6 +9,7 @@ add_lldb_library(lldbPluginProcessElfCore PLUGIN
   RegisterContextPOSIXCore_ppc64le.cpp
   RegisterContextPOSIXCore_s390x.cpp
   RegisterContextPOSIXCore_x86_64.cpp
+  RegisterContextPOSIXCore_riscv64.cpp
   RegisterUtilities.cpp
 
   LINK_LIBS
diff --git 
a/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp 
b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp
new file mode 100644
index 0..2202be4d38082
--- /dev/null
+++ b/lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_riscv64.cpp
@@ -0,0 +1,84 @@
+//===-- RegisterContextPOSIXCore_riscv64.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "RegisterContextPOSIXCore_riscv64.h"
+
+#include "lldb/Utility/DataBufferHeap.h"
+
+using namespace lldb_private;
+
+std::unique_ptr
+RegisterContextCorePOSIX_riscv64::Create(
+lldb_private::Thread , const lldb_private::ArchSpec ,
+const lldb_private::DataExtractor ,
+llvm::ArrayRef notes) {
+  Flags flags = 0;
+
+  auto register_info_up =
+  std::make_unique(arch, flags);
+  return std::unique_ptr(
+  new RegisterContextCorePOSIX_riscv64(thread, std::move(register_info_up),
+   gpregset, notes));
+}
+
+RegisterContextCorePOSIX_riscv64::RegisterContextCorePOSIX_riscv64(
+Thread , std::unique_ptr register_info,
+const DataExtractor , llvm::ArrayRef notes)
+: RegisterContextPOSIX_riscv64(thread, std::move(register_info)) {
+
+  m_gpr_buffer = std::make_shared(gpregset.GetDataStart(),
+  gpregset.GetByteSize());
+  m_gpr.SetData(m_gpr_buffer);
+  m_gpr.SetByteOrder(gpregset.GetByteOrder());
+
+  ArchSpec arch = m_register_info_up->GetTargetArchitecture();
+  DataExtractor fpregset = getRegset(notes, arch.GetTriple(), FPR_Desc);
+  m_fpr_buffer = std::make_shared(fpregset.GetDataStart(),
+  fpregset.GetByteSize());
+  m_fpr.SetData(m_fpr_buffer);
+  m_fpr.SetByteOrder(fpregset.GetByteOrder());
+}
+
+RegisterContextCorePOSIX_riscv64::~RegisterContextCorePOSIX_riscv64() = 
default;
+
+bool RegisterContextCorePOSIX_riscv64::ReadGPR() { return true; }
+
+bool RegisterContextCorePOSIX_riscv64::ReadFPR() { return true; }
+
+bool RegisterContextCorePOSIX_riscv64::WriteGPR() {
+  assert(0);
+  return false;
+}
+
+bool RegisterContextCorePOSIX_riscv64::WriteFPR() {
+  assert(0);
+  return false;
+}
+
+bool RegisterContextCorePOSIX_riscv64::ReadRegister(
+const RegisterInfo *reg_info, RegisterValue ) {
+  const uint8_t *src = nullptr;
+  lldb::offset_t offset = reg_info->byte_offset;
+
+  if (IsGPR(reg_info->kinds[lldb::eRegisterKindLLDB])) {
+src = m_gpr.GetDataStart();
+  } else { // IsFPR
+src = m_fpr.GetDataStart();
+offset -= GetGPRSize();
+  }
+
+  Status 

[Lldb-commits] [lldb] [lldb/DWARF] Refactor DWARFDIE::Get{Decl, TypeLookup}Context (PR #93291)

2024-05-29 Thread Michael Buch via lldb-commits

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

LGTM!

(seems like we could probably add unit-tests for this in 
`lldb/unittests/SymbolFile/DWARF/DWARFDIETest.cpp`? But not a blocker)

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


[Lldb-commits] [lldb] Add AddressRange to SB API (PR #92014)

2024-05-29 Thread David Spickett via lldb-commits

DavidSpickett wrote:

The new tests are flaky on Windows on Arm, I'm looking into it.

https://github.com/llvm/llvm-project/pull/92014
___
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-29 Thread Pavel Labath via lldb-commits

labath wrote:

> Discussed with Pavel, I applied this change to #92328 so we can ensure the 
> DIEs from the index is always definition DIEs and avoid duplicate/expensive 
> checks later.

To elaborate, I suggested Zequan does this, because I think there's consensus 
that this is a good way to filter out (incorrect) declaration dies from the 
index, and it's a better (faster) fix than what Zequan PR. It's still 
worthwhile to figure out where those entries are coming from. We know of one 
case with type units and that has now been fixed (thanks to David), if there 
are more, we should try to understand where they are coming from).

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] [WIP] [lldb][Progress] Report progress when completing types from DWARF (PR #91452)

2024-05-29 Thread Michael Buch via lldb-commits

Michael137 wrote:

Sorry for the delayed response, just got back from vacation.

> What do these numbers include? Is it just the operation it self, or 
> everything leading up to it as well. 
> Thanks for doing this. What do these numbers include? Is it just the 
> operation it self, or everything leading up to it as well. For example, is 
> "expr var" just the timing of the "expr" command, or attach command as well.

The benchmarks include the attach command as well. E.g., `expr var` would be 
the time it took to attach/stop at a breakpoint in Clang and run `expr`. I'll 
post the baseline shortly


https://github.com/llvm/llvm-project/pull/91452
___
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-29 Thread Pavel Labath via lldb-commits

labath wrote:

> I have a follow up question. 

It sounds like you've answered it yourself. :)

With this kind of debug info, lldb would think this refers to a global entity 
and return it for queries like `::InnerState`. Without that entry, lldb will 
(correctly) look up the context in the DIE tree, and compare it that way.

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] Remove DWARFDebugInfo DIERef footguns (PR #92894)

2024-05-29 Thread Pavel Labath 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  = *llvm::cast(
+m_module.GetSymbolFile()->GetBackingSymbolFile());

labath wrote:

And the future is here.

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-29 Thread Pavel Labath via lldb-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/92894

>From e416051b09147b1083765795f711bb972e42a893 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Mon, 20 May 2024 14:51:52 +
Subject: [PATCH] [lldb] Remove DWARFDebugInfo DIERef footguns

DWARFDebugInfo doesn't know how to resolve the "file_index" component of
a DIERef. This patch removes GetUnit (in favor of existing
GetUnitContainingDIEOffset) and changes GetDIE to take only the
components it actually uses.

In the process it fixes GetCompleteObjCClass, although that bug was
unlikely to be noticed, since ObjC is only really used on darwin, and
split DWARF isn't a thing there.
---
 .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp| 11 +++
 .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h  |  3 +--
 .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp  | 14 +++---
 .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp   |  7 ---
 .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp|  2 +-
 5 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
index d28da728728e5..c37cc91e08ed1 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
@@ -222,10 +222,6 @@ DWARFUnit *DWARFDebugInfo::GetUnitAtOffset(DIERef::Section 
section,
   return result;
 }
 
-DWARFUnit *DWARFDebugInfo::GetUnit(const DIERef _ref) {
-  return GetUnitContainingDIEOffset(die_ref.section(), die_ref.die_offset());
-}
-
 DWARFUnit *
 DWARFDebugInfo::GetUnitContainingDIEOffset(DIERef::Section section,
dw_offset_t die_offset) {
@@ -253,9 +249,8 @@ bool DWARFDebugInfo::ContainsTypeUnits() {
 //
 // Get the DIE (Debug Information Entry) with the specified offset.
 DWARFDIE
-DWARFDebugInfo::GetDIE(const DIERef _ref) {
-  DWARFUnit *cu = GetUnit(die_ref);
-  if (cu)
-return cu->GetNonSkeletonUnit().GetDIE(die_ref.die_offset());
+DWARFDebugInfo::GetDIE(DIERef::Section section, dw_offset_t die_offset) {
+  if (DWARFUnit *cu = GetUnitContainingDIEOffset(section, die_offset))
+return cu->GetNonSkeletonUnit().GetDIE(die_offset);
   return DWARFDIE(); // Not found
 }
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
index 456ebd908ccb2..4706b55d38ea9 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h
@@ -38,11 +38,10 @@ class DWARFDebugInfo {
  uint32_t *idx_ptr = nullptr);
   DWARFUnit *GetUnitContainingDIEOffset(DIERef::Section section,
 dw_offset_t die_offset);
-  DWARFUnit *GetUnit(const DIERef _ref);
   DWARFUnit *GetSkeletonUnit(DWARFUnit *dwo_unit);
   DWARFTypeUnit *GetTypeUnitForHash(uint64_t hash);
   bool ContainsTypeUnits();
-  DWARFDIE GetDIE(const DIERef _ref);
+  DWARFDIE GetDIE(DIERef::Section section, dw_offset_t die_offset);
 
   enum {
 eDumpFlag_Verbose = (1 << 0),  // Verbose dumping
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index 79400e36e04f3..31bbad3e56269 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -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  = *llvm::cast(
+m_module.GetSymbolFile()->GetBackingSymbolFile());
+DWARFDIE die = dwarf.GetDIE(*ref);
 if (!die) {
   ReportInvalidDIERef(*ref, class_name.GetStringRef());
   continue;
 }
+if (!die.GetCU()->Supports_DW_AT_APPLE_objc_complete_type()) {
+  incomplete_types.push_back(*ref);
+  continue;
+}
 
 if (die.GetAttributeValueAsUnsigned(DW_AT_APPLE_objc_complete_type, 0)) {
   // If we find the complete version we're done.
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index f6f152726bf74..2bca27936c76b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1748,7 +1748,8 @@ SymbolFileDWARF::GetDIE(const DIERef _ref) {
 if (SymbolFileDWARFDebugMap *debug_map = GetDebugMapSymfile()) {
   symbol_file = debug_map->GetSymbolFileByOSOIndex(*file_index); // OSO 
case
   if (symbol_file)
-return symbol_file->DebugInfo().GetDIE(die_ref);
+return 

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

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


@@ -0,0 +1,27 @@
+"""
+Test that we can set up software breakpoint even if we failed to decode and 
execute instruction
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestBreakpointIlligal(TestBase):

labath wrote:

typo (Illegal). Also in the file name.

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


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

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


@@ -94,6 +94,39 @@ static lldb::addr_t ReadFlags(NativeRegisterContext 
_context) {
  LLDB_INVALID_ADDRESS);
 }
 
+static int GetSoftwareWatchpointSize(const ArchSpec ,
+ lldb::addr_t next_flags) {
+  if (arch.GetMachine() == llvm::Triple::arm) {
+if (next_flags & 0x20)
+  // Thumb mode
+  return 2;
+else
+  // Arm mode
+  return 4;
+  }
+  if (arch.IsMIPS() || arch.GetTriple().isPPC64() ||
+  arch.GetTriple().isRISCV() || arch.GetTriple().isLoongArch())
+return 4;
+  return 0;
+}
+
+static Status SetSoftwareBreakPointOnPC(const ArchSpec , lldb::addr_t pc,

labath wrote:

We usually spell "break point" as a single word (i.e., `Breakpoint`).

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


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

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


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

labath wrote:

https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return

The rule is pretty subjective, but I think the fact you felt the need to add 
"opt" to the name shows the code is not completely understandable without it, 
and I'd say that spelling out the name is the more conventional way to express 
that. Also, (for better or worse) most of the lldb code (the surrounding code 
included) uses snake_case for variable name, so it's better to stick to that.

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


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

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


@@ -94,6 +94,39 @@ static lldb::addr_t ReadFlags(NativeRegisterContext 
_context) {
  LLDB_INVALID_ADDRESS);
 }
 
+static int GetSoftwareWatchpointSize(const ArchSpec ,
+ lldb::addr_t next_flags) {
+  if (arch.GetMachine() == llvm::Triple::arm) {
+if (next_flags & 0x20)
+  // Thumb mode
+  return 2;
+else
+  // Arm mode
+  return 4;
+  }
+  if (arch.IsMIPS() || arch.GetTriple().isPPC64() ||
+  arch.GetTriple().isRISCV() || arch.GetTriple().isLoongArch())
+return 4;
+  return 0;
+}
+
+static Status SetSoftwareBreakPointOnPC(const ArchSpec , lldb::addr_t pc,
+lldb::addr_t next_flags,
+NativeProcessProtocol ) {
+  int size_hint = GetSoftwareWatchpointSize(arch, next_flags);
+  Status error;
+  error = process.SetBreakpoint(pc, size_hint, /*hardware=*/false);
+
+  // If setting the breakpoint fails because pc is out of the address
+  // space, ignore it and let the debugee segfault.
+  if (error.GetError() == EIO || error.GetError() == EFAULT) {
+return Status();
+  } else if (error.Fail())

labath wrote:

https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return

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


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

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


@@ -94,6 +94,39 @@ static lldb::addr_t ReadFlags(NativeRegisterContext 
_context) {
  LLDB_INVALID_ADDRESS);
 }
 
+static int GetSoftwareWatchpointSize(const ArchSpec ,

labath wrote:

Doesn't this return the size of the *break*point (i.e. it should be called 
`GetSoftwareBreakpointSize` ?

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


[Lldb-commits] [lldb] [lldb-dap] Add timestamps to protocol logs (PR #93540)

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

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


[Lldb-commits] [lldb] 2cfea14 - [lldb-dap] Add timestamps to protocol logs (#93540)

2024-05-29 Thread via lldb-commits

Author: Pavel Labath
Date: 2024-05-29T09:27:32+02:00
New Revision: 2cfea14a57ad8443c6898d2310abb4346dc92ad2

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

LOG: [lldb-dap] Add timestamps to protocol logs (#93540)

I've found them very useful as a rudimentary form of benchmark.

Added: 


Modified: 
lldb/tools/lldb-dap/DAP.cpp

Removed: 




diff  --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index c7eb3db4304a9..d419f821999e6 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -103,7 +103,9 @@ void DAP::SendJSON(const llvm::json::Value ) {
   SendJSON(json_str);
 
   if (log) {
-*log << "<-- " << std::endl
+auto now = std::chrono::duration(
+std::chrono::system_clock::now().time_since_epoch());
+*log << llvm::formatv("{0:f9} <-- ", now.count()).str() << std::endl
  << "Content-Length: " << json_str.size() << "\r\n\r\n"
  << llvm::formatv("{0:2}", json).str() << std::endl;
   }
@@ -130,9 +132,12 @@ std::string DAP::ReadJSON() {
   if (!input.read_full(log.get(), length, json_str))
 return json_str;
 
-  if (log)
-*log << "--> " << std::endl << "Content-Length: " << length << "\r\n\r\n";
-
+  if (log) {
+auto now = std::chrono::duration(
+std::chrono::system_clock::now().time_since_epoch());
+*log << llvm::formatv("{0:f9} --> ", now.count()).str() << std::endl
+ << "Content-Length: " << length << "\r\n\r\n";
+  }
   return json_str;
 }
 



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


[Lldb-commits] [lldb] [lldb/DWARF] Bypass the compres^Wconstruction of DIERefs in debug_names (PR #93296)

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

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


[Lldb-commits] [lldb] 53d79fe - [lldb/DWARF] Bypass the compres^Wconstruction of DIERefs in debug_names (#93296)

2024-05-29 Thread via lldb-commits

Author: Pavel Labath
Date: 2024-05-29T09:17:24+02:00
New Revision: 53d79feec93ef99e2ba0ac8cfc6cf2f81d28bf8a

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

LOG: [lldb/DWARF] Bypass the compres^Wconstruction of DIERefs in debug_names 
(#93296)

DebugNamesDWARFIndex was jumping through hoops to construct a DIERef
from an index entry only to jump through them back a short while later
to construct a DWARFDIE.

This used to be necessary as the index lookup was a two stage process,
where we first enumerated all matches, and then examined them (so it was
important that the enumeration was cheap -- does not trigger unnecessary
parsing). However, now that the processing is callback based, we are
always immediately examining the DWARFDIE right after finding the entry,
and the DIERef just gets in the way.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
index 33537df4f5076..1703597a7cd2f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp
@@ -284,8 +284,12 @@ void AppleDWARFIndex::GetFunctions(
   for (const auto  : m_apple_names_up->equal_range(name)) {
 DIERef die_ref(std::nullopt, DIERef::Section::DebugInfo,
*entry.getDIESectionOffset());
-if (!ProcessFunctionDIE(lookup_info, die_ref, dwarf, parent_decl_ctx,
-callback))
+DWARFDIE die = dwarf.GetDIE(die_ref);
+if (!die) {
+  ReportInvalidDIERef(die_ref, name);
+  continue;
+}
+if (!ProcessFunctionDIE(lookup_info, die, parent_decl_ctx, callback))
   return;
   }
 }

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
index 20c07a94b5076..30fb5d5ebdb0d 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
@@ -24,16 +24,11 @@ using namespace lldb_private::plugin::dwarf;
 DWARFIndex::~DWARFIndex() = default;
 
 bool DWARFIndex::ProcessFunctionDIE(
-const Module::LookupInfo _info, DIERef ref, SymbolFileDWARF ,
+const Module::LookupInfo _info, DWARFDIE die,
 const CompilerDeclContext _decl_ctx,
 llvm::function_ref callback) {
   llvm::StringRef name = lookup_info.GetLookupName().GetStringRef();
   FunctionNameType name_type_mask = lookup_info.GetNameTypeMask();
-  DWARFDIE die = dwarf.GetDIE(ref);
-  if (!die) {
-ReportInvalidDIERef(ref, name);
-return true;
-  }
 
   if (!(name_type_mask & eFunctionNameTypeFull)) {
 ConstString name_to_match_against;

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
index 0551b07100a96..cb3ae8a06d788 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
@@ -81,11 +81,10 @@ class DWARFIndex {
   StatsDuration m_index_time;
 
   /// Helper function implementing common logic for processing function dies. 
If
-  /// the function given by "ref" matches search criteria given by
-  /// "parent_decl_ctx" and "name_type_mask", it is inserted into the "dies"
-  /// vector.
-  bool ProcessFunctionDIE(const Module::LookupInfo _info, DIERef ref,
-  SymbolFileDWARF ,
+  /// the function given by "die" matches search criteria given by
+  /// "parent_decl_ctx" and "name_type_mask", it calls the callback with the
+  /// given die.
+  bool ProcessFunctionDIE(const Module::LookupInfo _info, DWARFDIE die,
   const CompilerDeclContext _decl_ctx,
   llvm::function_ref callback);
 

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
index c98e5481609de..56717bab1ecd8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp
@@ -64,27 +64,25 @@ DebugNamesDWARFIndex::GetNonSkeletonUnit(const 
DebugNames::Entry ) const {
   return cu ? >GetNonSkeletonUnit() : nullptr;
 }
 
-std::optional
-DebugNamesDWARFIndex::ToDIERef(const DebugNames::Entry ) const {
+DWARFDIE DebugNamesDWARFIndex::GetDIE(const DebugNames::Entry ) const {
   DWARFUnit *unit = GetNonSkeletonUnit(entry);
-  if (!unit)
-return std::nullopt;
-  if 

[Lldb-commits] [lldb] [lldb/DWARF] Bypass the compres^Wconstruction of DIERefs in debug_names (PR #93296)

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


@@ -183,27 +181,22 @@ void DebugNamesDWARFIndex::GetCompleteObjCClass(
 llvm::function_ref callback) {
   // Keep a list of incomplete types as fallback for when we don't find the
   // complete type.
-  DIEArray incomplete_types;
+  std::vector incomplete_types;

labath wrote:

Thanks.

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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

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


@@ -0,0 +1,142 @@
+"""
+Test lldb-dap "port" configuration to "attach" request
+"""
+
+
+import dap_server
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test import lldbplatformutil
+import lldbgdbserverutils
+import lldbdap_testcase
+import os
+import shutil
+import subprocess
+import tempfile
+import threading
+import time
+import sys
+import socket
+
+
+class TestDAP_attachByPortNum(lldbdap_testcase.DAPTestCaseBase):
+def get_free_port(self):
+s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+s.bind(("", 0))
+port = s.getsockname()[1]
+s.close()
+return port

labath wrote:

That's better (for some definition of the word), but it still doesn't guarantee 
you avoid races. The fact that the port is free at this point doesn't guarantee 
the port will still be free when the lldb-server attempts to use it. When 
running the test suite, you can have a hundred of tests attempting to allocate 
ports in parallel, so it's just a matter of time before something collides. 
What you really want is for lldb-server to allocate the port and let the test 
suite know which port it has chosen without closing it in between (that's what 
the code I pointed you to does).

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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

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

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


[Lldb-commits] [lldb] [lldb-dap] Added "port" property to vscode "attach" command. (PR #91570)

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

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

You did not respond to my comment about generalizing this to accept a single 
"url" parameter. I'm not saying it has to be implemented that way, but I would 
like to hear your thoughts on it, as it definitely has some advantages (and it 
sounds like Walter agrees).

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