[Lldb-commits] [lldb] [lldb] Expose discontinuous functions through SBFunction::GetRanges (PR #117532)

2024-12-02 Thread Alex Langford via lldb-commits


@@ -444,8 +444,11 @@ class Function : public UserID, public SymbolContextScope {
 
   Function *CalculateSymbolContextFunction() override;
 
+  // DEPRECATED: Use GetAddressRanges instead.

bulbazord wrote:

Can you make this into a Doxygen comment? It will show up in the generated 
documentation (for those who use it).

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


[Lldb-commits] [lldb] [lldb] Expose discontinuous functions through SBFunction::GetRanges (PR #117532)

2024-12-02 Thread Alex Langford via lldb-commits


@@ -0,0 +1,182 @@
+# REQUIRES: x86

bulbazord wrote:

Is there any way we can have an architecture-independent test? If it's a ton of 
work, I say don't worry about it, most folks are going to build the x86 target 
probably.

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


[Lldb-commits] [lldb] [lldb] Added an exponential algorithm for the sleep time in connect_to_debug_monitor() (PR #118222)

2024-12-02 Thread Pavel Labath via lldb-commits

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

Yeah, that's the general idea, although 16 attempts @ 262s sounds a bit too 
much (that's like almost three times as long as the first version with 30*3s). 
I worry that the tests will take too long to time out if they not able to 
establish a connection due to some other reason (like, imagine a bad patch 
causes lldb-server to never accept a connection). I'd suggest starting out with 
10attempts@77 seconds. That's still higher than the initial ~60 seconds, and I 
really hope that should be enough since doubling the port range sort of doubles 
the number of attempts as well (by halving the chance of collision).

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


[Lldb-commits] [lldb] [lldb][Process/Linux] Introduce LoongArch64 hw break/watchpoint support (PR #118043)

2024-12-02 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett commented:

I started to comment on some style issues here then realised that this code is 
adapted from 
`lldb/source/Plugins/Process/Utility/NativeRegisterContextDBReg_arm64.cpp` and 
I think about 90% of it is the same.

I would prefer that you extract the generic parts of the code into a generic 
`NativeRegisterContextDBReg` then have Arm64 and LoongArch specialise that.

It's one more level of classes in an already deep hierarchy but in this case I 
think the overlap is large enough to justify it.

This also solves little things like the name of `g_enable_bit` being too 
generic for a global in a file that does things other than breakpoints. If it's 
in a file specific to breakpoints, the name is ok.

`GetWatchpointSize` is an example of something that will need to be per 
architecture but 
`ClearHardwareBreakpoint` is the same for both so it can go in a base class.

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


[Lldb-commits] [lldb] [lldb][Process/Linux] Introduce LoongArch64 hw break/watchpoint support (PR #118043)

2024-12-02 Thread David Spickett via lldb-commits

DavidSpickett wrote:

We could move all this back into NativeRegisterContextLinux too but A: let's 
take one step at a time and B: it may be that some architecture does not fit 
the pattern that AArch64 and LoongArch do.

So in the interests of you getting this done and us having less churn, stick to 
making a NativeRegisterContextDBReg class.

One of these days maybe we'll hoist it further up.

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


[Lldb-commits] [lldb] Bugfix: Not showing the synthetic children of values behind pointers (PR #117755)

2024-12-02 Thread Sergey Kuznetsov via lldb-commits

skuznetsov wrote:

> Can you post a copy of a the python code for the synthetic child provider you 
> are creating and also how you are registering it with LLDB?

Here it is:
```
# Hash(K,V) class support providers
class CrystalHashSyntheticProvider:
def __init__(self, valobj, internal_dict):
self.valobj = valobj
self.extract_entries()

def has_children(self):
return True

def num_children(self):
size = self.valobj.GetChildMemberWithName("size").unsigned
return size

def get_child_index(self, name):
name = name.lstrip('[').rstrip(']')
if name == "size":
return len(self._entries) + 1 if self._entries else 1
try:
idx = next((index for index, obj in enumerate(self._entries) if 
getattr(self._entries, "key") == name), -1)
return idx
except:
return -1

def get_child_at_index(self, index):
if index > len(self.entries):
return None
if index == len(self.entries):
return self.valobj.GetChildMemberWithName("size")
entry = self.entries[index]
key = entry.GetChildMemberWithName("key").GetSummary()
value = entry.GetChildMemberWithName("value").deref
return value.CreateChildAtOffset("[%s]" % key, 0, value.type)
# return entry.CreateChildAtOffset("[%d]" % index, 0, entry.type)

def extract_entries(self):
if self.valobj.type.is_pointer:
self.valobj = self.valobj.Dereference()
self.size = 0 if self.valobj.GetChildMemberWithName("size").value is 
None else self.valobj.GetChildMemberWithName("size").unsigned
self.entries = []

for index in range(self.size):
try:
valuePath = "entries[%d]" % index
value = self.valobj.EvaluateExpression(valuePath)
if value.type.is_pointer:
value = value.deref
self.entries.append(value)

except Exception as e:
print('Got exception %s' % (str(e)))
return None
print ("Created %d entries." % len(self.entries))

```

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


[Lldb-commits] [lldb] [lldb] Added an exponential algorithm for the sleep time in connect_to_debug_monitor() (PR #118222)

2024-12-02 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman updated 
https://github.com/llvm/llvm-project/pull/118222

>From bb68e6d523f3e80b991c7370bb00bac2bb9582b6 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sun, 1 Dec 2024 21:35:52 +0400
Subject: [PATCH 1/3] [lldb] Increase MAX_ATTEMPTS in
 connect_to_debug_monitor()

See #118032 for details.
---
 .../lldbsuite/test/tools/lldb-server/gdbremote_testcase.py  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 8c8e4abed0b454..67b07ff4ddd998 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -388,7 +388,7 @@ def connect_to_debug_monitor(self, attach_pid=None):
 # We're using a random port algorithm to try not to collide with other 
ports,
 # and retry a max # times.
 attempts = 0
-MAX_ATTEMPTS = 20
+MAX_ATTEMPTS = 30
 
 while attempts < MAX_ATTEMPTS:
 server = self.launch_debug_monitor(attach_pid=attach_pid)

>From a9a7e4e50d788aeb22bfe94a4ca580e9045882e3 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Mon, 2 Dec 2024 15:17:28 +0400
Subject: [PATCH 2/3] Added an exponential algorithm for the sleep time.
 Reduced MAX_ATTEMPTS to 16. The sleep time will be 3, 3.6, 4.3, ..., 38, 46.
 The total sleep time is 262 + 0.5*MAX_CONNECT_ATTEMPTS*MAX_ATTEMPTS = 342.
 Note the timeout is 600, so the rest time must be enough. Increased the port
 range (12000..2).

---
 .../test/tools/lldb-server/gdbremote_testcase.py  | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 67b07ff4ddd998..04d39bfc74299c 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -185,7 +185,7 @@ def setUpServerLogging(self, is_llgs):
 ]
 
 def get_next_port(self):
-return 12000 + random.randint(0, 3999)
+return 12000 + random.randint(0, 7999)
 
 def reset_test_sequence(self):
 self.test_sequence = GdbRemoteTestSequence(self.logger)
@@ -388,7 +388,8 @@ def connect_to_debug_monitor(self, attach_pid=None):
 # We're using a random port algorithm to try not to collide with other 
ports,
 # and retry a max # times.
 attempts = 0
-MAX_ATTEMPTS = 30
+MAX_ATTEMPTS = 16
+attempt_wait = 3
 
 while attempts < MAX_ATTEMPTS:
 server = self.launch_debug_monitor(attach_pid=attach_pid)
@@ -424,7 +425,8 @@ def connect_to_debug_monitor(self, attach_pid=None):
 
 # And wait a random length of time before next attempt, to avoid
 # collisions.
-time.sleep(random.randint(1, 5))
+time.sleep(attempt_wait)
+attempt_wait *= 1.2
 
 # Now grab a new port number.
 self.port = self.get_next_port()

>From 40e9a0f11223ba165b3cacde52d16d69737b6de5 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Mon, 2 Dec 2024 17:48:51 +0400
Subject: [PATCH 3/3] Reduced MAX_ATTEMPTS to 10.

---
 .../lldbsuite/test/tools/lldb-server/gdbremote_testcase.py  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 04d39bfc74299c..d6cb68f55bf296 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -388,7 +388,7 @@ def connect_to_debug_monitor(self, attach_pid=None):
 # We're using a random port algorithm to try not to collide with other 
ports,
 # and retry a max # times.
 attempts = 0
-MAX_ATTEMPTS = 16
+MAX_ATTEMPTS = 10
 attempt_wait = 3
 
 while attempts < MAX_ATTEMPTS:

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


[Lldb-commits] [lldb] [lldb/DWARF] Remove duplicate type filtering (PR #116989)

2024-12-02 Thread Michael Buch via lldb-commits

Michael137 wrote:

Apologies for the late ping but looks like this is breaking macOS CI: 
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/16280/execution/node/97/log/?consoleFull
```
==
FAIL: test_shadowed_static_inline_members_dwarf5_dsym 
(TestConstStaticIntegralMember.TestCase)
--
Traceback (most recent call last):
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 1770, in test_method
return attrvalue(self)
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py",
 line 205, in test_shadowed_static_inline_members_dwarf5
self.check_shadowed_static_inline_members("-gdwarf-5")
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/lang/cpp/const_static_integral_member/TestConstStaticIntegralMember.py",
 line 197, in check_shadowed_static_inline_members
self.expect_expr("::Foo::mem", result_value="-29")
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 2526, in expect_expr
value_check.check_value(self, eval_result, str(eval_result))
  File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 310, in check_value
test_base.assertEqual(self.expect_value, val.GetValue(), this_error_msg)
AssertionError: '-29' != '10'
- -29
+ 10
 : (const int) $3 = 10
Checking SBValue: (const int) $3 = 10
Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang
--
Ran 24 tests in 20.144s
```

Note this is the `dsym` test variant (and on macOS we XFAIL it for the `dwarf` 
variant). I haven't yet checked whether the assertion is bogus or not

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


[Lldb-commits] [lldb] Bugfix: Not showing the synthetic children of values behind pointers (PR #117755)

2024-12-02 Thread Sergey Kuznetsov via lldb-commits

skuznetsov wrote:

>  src="https://private-user-images.githubusercontent.com/4421997/391664786-b7dbb80c-5f7d-4dd8-a0db-d0b8fe10cf21.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzMxNjQxODMsIm5iZiI6MTczMzE2Mzg4MywicGF0aCI6Ii80NDIxOTk3LzM5MTY2NDc4Ni1iN2RiYjgwYy01ZjdkLTRkZDgtYTBkYi1kMGI4ZmUxMGNmMjEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MTIwMiUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDEyMDJUMTgyNDQzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTRkODk3NjRhNThjZmE2ZGE5Yzg0YjQxMzgyMDY2NWMxZGE4OGI1NDM0ZGRjZWJhMDVkZjg3ZmMxNzE2YjJlMiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.hjCRHnWRytRb8EiK6D5omVOi7WWXogpogZzsG_NswF0";>
> Still works inside of a structure. Anything else I can try?

I tried your example and modified it in a similar way: embedded pointer to 
another vector, and it was working as expected.

So, I am still investigating what can be wrong here.

I am digging through the ll file for the code to find the debug declarations to 
recover the type.
I tried to do it via lldb, but when I type 'type lookup LavinMQ::VHostStore', 
it does not find it. I suspect due to the special characters "::" that are used 
for namespace separation.


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


[Lldb-commits] [lldb] Fix the DWARF index cache when index is partial. (PR #118390)

2024-12-02 Thread Greg Clayton via lldb-commits

https://github.com/clayborg created 
https://github.com/llvm/llvm-project/pull/118390

The ManualDWARFIndex class can create a index cache if the LLDB index cache is 
enabled. This used to save the index to the same file, regardless of wether the 
cache was a full index (no .debug_names) or a partial index (have .debug_names, 
but not all .o files were had .debug_names). So we could end up saving an index 
cache that was partial, and then later load that partial index as if it were a 
full index if the user set the 'settings set 
plugin.symbol-file.dwarf.ignore-file-indexes true'. This would cause us to 
ignore the .debug_names section, and if the index cache was enabled, we could 
end up loading the partial index as if it were a full DWARF index.

This patch detects when the ManualDWARFIndex is being used with .debug_names, 
and saves out a cache file with a suffix of "-full" or "-partial" to avoid this 
issue.

>From 8aa3f18f57908b4d1e5932ea5de94cf183b2542e Mon Sep 17 00:00:00 2001
From: Greg Clayton 
Date: Mon, 2 Dec 2024 11:35:25 -0800
Subject: [PATCH] Fix the DWARF index cache when index is partial.

The ManualDWARFIndex class can create a index cache if the LLDB index cache is 
enabled. This used to save the index to the same file, regardless of wether the 
cache was a full index (no .debug_names) or a partial index (have .debug_names, 
but not all .o files were had .debug_names). So we could end up saving an index 
cache that was partial, and then later load that partial index as if it were a 
full index if the user set the 'settings set 
plugin.symbol-file.dwarf.ignore-file-indexes true'. This would cause us to 
ignore the .debug_names section, and if the index cache was enabled, we could 
end up loading the partial index as if it were a full DWARF index.

This patch detects when the ManualDWARFIndex is being used with .debug_names, 
and saves out a cache file with a suffix of "-full" or "-partial" to avoid this 
issue.
---
 .../SymbolFile/DWARF/ManualDWARFIndex.cpp | 24 ++-
 .../SymbolFile/DWARF/ManualDWARFIndex.h   | 10 +++
 .../SymbolFile/DWARF/x86/dwp-index-cache.cpp  | 62 +++
 3 files changed, 95 insertions(+), 1 deletion(-)
 create mode 100644 lldb/test/Shell/SymbolFile/DWARF/x86/dwp-index-cache.cpp

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 1220e6115a2a95..0be19ab29ef082 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -706,6 +706,11 @@ bool ManualDWARFIndex::Encode(DataEncoder &encoder) const {
   return true;
 }
 
+bool ManualDWARFIndex::IsPartial() const {
+  // If we have units or type units to skip, then this index is partial.
+  return !m_units_to_avoid.empty() || !m_type_sigs_to_avoid.empty();
+}
+
 std::string ManualDWARFIndex::GetCacheKey() {
   std::string key;
   llvm::raw_string_ostream strm(key);
@@ -713,9 +718,26 @@ std::string ManualDWARFIndex::GetCacheKey() {
   // module can have one object file as the main executable and might have
   // another object file in a separate symbol file, or we might have a .dwo 
file
   // that claims its module is the main executable.
+
+  // This class can be used to index all of the DWARF, or part of the DWARF
+  // when there is a .debug_names index where some compile or type units were
+  // built without .debug_names. So we need to know when we have a full manual
+  // DWARF index or a partial manual DWARF index and save them to different
+  // cache files. Before this fix we might end up debugging a binary with
+  // .debug_names where some of the compile or type units weren't indexed, and
+  // find an issue with the .debug_names tables (bugs or being incomplete), and
+  // then we disable loading the .debug_names by setting a setting in LLDB by
+  // running "settings set plugin.symbol-file.dwarf.ignore-file-indexes 0" in
+  // another LLDB instance. The problem arose when there was an index cache 
from
+  // a previous run where .debug_names was enabled and it had saved a cache 
file
+  // that only covered the missing compile and type units from the 
.debug_names,
+  // and with the setting that disables the loading of the cache files we would
+  // load partial cache index cache. So we need to pick a unique cache suffix
+  // name that indicates if the cache is partial or full to avoid this problem.
+  llvm::StringRef dwarf_index_suffix(IsPartial() ? "partial-" : "full-");
   ObjectFile *objfile = m_dwarf->GetObjectFile();
   strm << objfile->GetModule()->GetCacheKey() << "-dwarf-index-"
-  << llvm::format_hex(objfile->GetCacheHash(), 10);
+   << dwarf_index_suffix << llvm::format_hex(objfile->GetCacheHash(), 10);
   return key;
 }
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
index d8c4a22ab21f7b..6a52c88a99220f 100644
--- a/lldb/s

[Lldb-commits] [lldb] Fix the DWARF index cache when index is partial. (PR #118390)

2024-12-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Greg Clayton (clayborg)


Changes

The ManualDWARFIndex class can create a index cache if the LLDB index cache is 
enabled. This used to save the index to the same file, regardless of wether the 
cache was a full index (no .debug_names) or a partial index (have .debug_names, 
but not all .o files were had .debug_names). So we could end up saving an index 
cache that was partial, and then later load that partial index as if it were a 
full index if the user set the 'settings set 
plugin.symbol-file.dwarf.ignore-file-indexes true'. This would cause us to 
ignore the .debug_names section, and if the index cache was enabled, we could 
end up loading the partial index as if it were a full DWARF index.

This patch detects when the ManualDWARFIndex is being used with .debug_names, 
and saves out a cache file with a suffix of "-full" or "-partial" to avoid this 
issue.

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


3 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp (+23-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h (+10) 
- (added) lldb/test/Shell/SymbolFile/DWARF/x86/dwp-index-cache.cpp (+62) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index 1220e6115a2a95..0be19ab29ef082 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -706,6 +706,11 @@ bool ManualDWARFIndex::Encode(DataEncoder &encoder) const {
   return true;
 }
 
+bool ManualDWARFIndex::IsPartial() const {
+  // If we have units or type units to skip, then this index is partial.
+  return !m_units_to_avoid.empty() || !m_type_sigs_to_avoid.empty();
+}
+
 std::string ManualDWARFIndex::GetCacheKey() {
   std::string key;
   llvm::raw_string_ostream strm(key);
@@ -713,9 +718,26 @@ std::string ManualDWARFIndex::GetCacheKey() {
   // module can have one object file as the main executable and might have
   // another object file in a separate symbol file, or we might have a .dwo 
file
   // that claims its module is the main executable.
+
+  // This class can be used to index all of the DWARF, or part of the DWARF
+  // when there is a .debug_names index where some compile or type units were
+  // built without .debug_names. So we need to know when we have a full manual
+  // DWARF index or a partial manual DWARF index and save them to different
+  // cache files. Before this fix we might end up debugging a binary with
+  // .debug_names where some of the compile or type units weren't indexed, and
+  // find an issue with the .debug_names tables (bugs or being incomplete), and
+  // then we disable loading the .debug_names by setting a setting in LLDB by
+  // running "settings set plugin.symbol-file.dwarf.ignore-file-indexes 0" in
+  // another LLDB instance. The problem arose when there was an index cache 
from
+  // a previous run where .debug_names was enabled and it had saved a cache 
file
+  // that only covered the missing compile and type units from the 
.debug_names,
+  // and with the setting that disables the loading of the cache files we would
+  // load partial cache index cache. So we need to pick a unique cache suffix
+  // name that indicates if the cache is partial or full to avoid this problem.
+  llvm::StringRef dwarf_index_suffix(IsPartial() ? "partial-" : "full-");
   ObjectFile *objfile = m_dwarf->GetObjectFile();
   strm << objfile->GetModule()->GetCacheKey() << "-dwarf-index-"
-  << llvm::format_hex(objfile->GetCacheHash(), 10);
+   << dwarf_index_suffix << llvm::format_hex(objfile->GetCacheHash(), 10);
   return key;
 }
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h 
b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
index d8c4a22ab21f7b..6a52c88a99220f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h
@@ -168,6 +168,16 @@ class ManualDWARFIndex : public DWARFIndex {
 const lldb::LanguageType cu_language,
 IndexSet &set);
 
+  /// Return true if this manual DWARF index is covering only part of the 
DWARF.
+  ///
+  /// An instance of this class will be used to index all of the DWARF, but 
also
+  /// when we have .debug_names we will use one to index any compile or type
+  /// units that are not covered by the .debug_names table.
+  ///
+  /// \return
+  ///   True if this index is a partial index, false otherwise.
+  bool IsPartial() const;
+
   /// The DWARF file which we are indexing.
   SymbolFileDWARF *m_dwarf;
   /// Which dwarf units should we skip while building the index.
diff --git a/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-index-cache.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/dwp-index-cache.cpp
new file mode 100644
index

[Lldb-commits] [lldb] [lldb] Update dwim-print to support limited variable expression paths (PR #117452)

2024-12-02 Thread Augusto Noronha via lldb-commits

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


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


[Lldb-commits] [lldb] Bugfix: Not showing the synthetic children of values behind pointers (PR #117755)

2024-12-02 Thread Greg Clayton via lldb-commits

clayborg wrote:

Can you post a copy of a the python code for the synthetic child provider you 
are creating and also how you are registering it with LLDB?

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


[Lldb-commits] [lldb] [lldb] Fix the DWARF index cache when index is partial. (PR #118390)

2024-12-02 Thread Greg Clayton via lldb-commits

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


[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #115331)

2024-12-02 Thread Kyungwoo Lee via lldb-commits


@@ -88,9 +89,10 @@ Expected llvm::localCache(const Twine 
&CacheNameRef,
 AddBuffer(std::move(AddBuffer)), TempFile(std::move(TempFile)),
 ModuleName(ModuleName), Task(Task) {}
 
-  ~CacheStream() {
-// TODO: Manually commit rather than using non-trivial destructor,
-// allowing to replace report_fatal_errors with a return Error.
+  Error commit() override {
+if (Committed)
+  return Error::success();

kyulee-com wrote:

Intuitively, this doesn't seem correct. Shouldn't we fail if we attempt to 
commit more than once, rather than just returning a success?
Additionally, I'm curious about what happens if we use this CacheStream after a 
commit has been called. I suspect it will fail, but do we provide a proper 
error message in this case? It would be ideal to have a test case to cover 
these scenarios.

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


[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #115331)

2024-12-02 Thread Kyungwoo Lee via lldb-commits


@@ -131,11 +138,22 @@ Expected llvm::localCache(const Twine 
&CacheNameRef,
 });
 
 if (E)
-  report_fatal_error(Twine("Failed to rename temporary file ") +
- TempFile.TmpName + " to " + ObjectPathName + ": " 
+
- toString(std::move(E)) + "\n");
+  return E;
 
 AddBuffer(Task, ModuleName, std::move(*MBOrErr));
+return Error::success();
+  }
+
+  ~CacheStream() {
+// In Debug builds, try to track down places where commit() was not
+// called before destruction.
+assert(Committed);

kyulee-com wrote:

While I understand the intent here, it's unusual to have different behavior in 
debug and release modes. The release mode operation, where commit() is 
essentially optional because it's handled by the destructor, seems reasonable 
to me. For consistency, I would prefer to remove this assert, although you can 
use it for testing purposes. Are you aiming to use commit() optionally to make 
error messages more explicit?

Alternatively, if we require commit() to be used instead of relying on the 
destructor, I would suggest explicitly failing or emitting a warning if it 
hasn't been committed beforehand.

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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

2024-12-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)


Changes

This is most useful if you are listening on an address like 'localhost:0' and 
want to know the resolved ip + port of the socket listener.

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


6 Files Affected:

- (modified) lldb/include/lldb/Host/Socket.h (+3) 
- (modified) lldb/include/lldb/Host/common/TCPSocket.h (+2) 
- (modified) lldb/include/lldb/Host/posix/DomainSocket.h (+2) 
- (modified) lldb/source/Host/common/TCPSocket.cpp (+19-3) 
- (modified) lldb/source/Host/posix/DomainSocket.cpp (+16-1) 
- (modified) lldb/unittests/Host/SocketTest.cpp (+44-7) 


``diff
diff --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h
index e98797b36c8a5d..c937e0c02ff19e 100644
--- a/lldb/include/lldb/Host/Socket.h
+++ b/lldb/include/lldb/Host/Socket.h
@@ -151,6 +151,9 @@ class Socket : public IOObject {
   // If this Socket is connected then return the URI used to connect.
   virtual std::string GetRemoteConnectionURI() const { return ""; };
 
+  // If the Socket is listening then return the URI for clients to connect.
+  virtual std::string GetListeningConnectionURI() const { return ""; }
+
 protected:
   Socket(SocketProtocol protocol, bool should_close);
 
diff --git a/lldb/include/lldb/Host/common/TCPSocket.h 
b/lldb/include/lldb/Host/common/TCPSocket.h
index ca36622691fe9a..ab6bf5ab97cae7 100644
--- a/lldb/include/lldb/Host/common/TCPSocket.h
+++ b/lldb/include/lldb/Host/common/TCPSocket.h
@@ -52,6 +52,8 @@ class TCPSocket : public Socket {
 
   std::string GetRemoteConnectionURI() const override;
 
+  std::string GetListeningConnectionURI() const override;
+
 private:
   TCPSocket(NativeSocket socket, const TCPSocket &listen_socket);
 
diff --git a/lldb/include/lldb/Host/posix/DomainSocket.h 
b/lldb/include/lldb/Host/posix/DomainSocket.h
index d4e0d43ee169c1..d79564cc76dafd 100644
--- a/lldb/include/lldb/Host/posix/DomainSocket.h
+++ b/lldb/include/lldb/Host/posix/DomainSocket.h
@@ -27,6 +27,8 @@ class DomainSocket : public Socket {
 
   std::string GetRemoteConnectionURI() const override;
 
+  std::string GetListeningConnectionURI() const override;
+
 protected:
   DomainSocket(SocketProtocol protocol);
 
diff --git a/lldb/source/Host/common/TCPSocket.cpp 
b/lldb/source/Host/common/TCPSocket.cpp
index 5d863954ee8868..b7bd62ff04855e 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -81,6 +81,12 @@ std::string TCPSocket::GetLocalIPAddress() const {
 socklen_t sock_addr_len = sock_addr.GetMaxLength();
 if (::getsockname(m_socket, sock_addr, &sock_addr_len) == 0)
   return sock_addr.GetIPAddress();
+  } else if (!m_listen_sockets.empty()) {
+SocketAddress sock_addr;
+socklen_t sock_addr_len = sock_addr.GetMaxLength();
+if (::getsockname(m_listen_sockets.begin()->first, sock_addr,
+  &sock_addr_len) == 0)
+  return sock_addr.GetIPAddress();
   }
   return "";
 }
@@ -115,6 +121,15 @@ std::string TCPSocket::GetRemoteConnectionURI() const {
   return "";
 }
 
+std::string TCPSocket::GetListeningConnectionURI() const {
+  if (!m_listen_sockets.empty()) {
+return std::string(llvm::formatv(
+"connection://[{0}]:{1}", GetLocalIPAddress(), GetLocalPortNumber()));
+  }
+
+  return "";
+}
+
 Status TCPSocket::CreateSocket(int domain) {
   Status error;
   if (IsValid())
@@ -176,8 +191,9 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 
   if (host_port->hostname == "*")
 host_port->hostname = "0.0.0.0";
-  std::vector addresses = SocketAddress::GetAddressInfo(
-  host_port->hostname.c_str(), nullptr, AF_UNSPEC, SOCK_STREAM, 
IPPROTO_TCP);
+  std::vector addresses =
+  SocketAddress::GetAddressInfo(host_port->hostname.c_str(), nullptr,
+AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
   for (SocketAddress &address : addresses) {
 int fd =
 Socket::CreateSocket(address.GetFamily(), kType, IPPROTO_TCP, error);
@@ -191,7 +207,7 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 }
 
 SocketAddress listen_address = address;
-if(!listen_address.IsLocalhost())
+if (!listen_address.IsLocalhost())
   listen_address.SetToAnyAddress(address.GetFamily(), host_port->port);
 else
   listen_address.SetPort(host_port->port);
diff --git a/lldb/source/Host/posix/DomainSocket.cpp 
b/lldb/source/Host/posix/DomainSocket.cpp
index 0451834630d33f..beec3c225ecc62 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -86,7 +86,8 @@ Status DomainSocket::Connect(llvm::StringRef name) {
   if (error.Fail())
 return error;
   if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),
-(struct sockaddr *)&saddr_un, saddr_un_len) < 0)
+  (struct sockaddr *)&saddr_un,
+  saddr_

[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

2024-12-02 Thread John Harrison via lldb-commits

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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

2024-12-02 Thread John Harrison via lldb-commits

https://github.com/ashgti updated 
https://github.com/llvm/llvm-project/pull/118330

>From c3226b620bc8f745b92b3aca7b189803a24db788 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Mon, 2 Dec 2024 08:29:01 -0800
Subject: [PATCH 1/2] [lldb] For a host socket, add a method to print the
 listening address.

This is most useful if you are listening on an address like 'localhost:0' and 
want to know the resolved ip + port of the socket listeniner.
---
 lldb/include/lldb/Host/Socket.h |  3 ++
 lldb/include/lldb/Host/common/TCPSocket.h   |  2 +
 lldb/include/lldb/Host/posix/DomainSocket.h |  2 +
 lldb/source/Host/common/TCPSocket.cpp   | 22 +++--
 lldb/source/Host/posix/DomainSocket.cpp | 17 ++-
 lldb/unittests/Host/SocketTest.cpp  | 51 ++---
 6 files changed, 86 insertions(+), 11 deletions(-)

diff --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h
index e98797b36c8a5d..c937e0c02ff19e 100644
--- a/lldb/include/lldb/Host/Socket.h
+++ b/lldb/include/lldb/Host/Socket.h
@@ -151,6 +151,9 @@ class Socket : public IOObject {
   // If this Socket is connected then return the URI used to connect.
   virtual std::string GetRemoteConnectionURI() const { return ""; };
 
+  // If the Socket is listening then return the URI for clients to connect.
+  virtual std::string GetListeningConnectionURI() const { return ""; }
+
 protected:
   Socket(SocketProtocol protocol, bool should_close);
 
diff --git a/lldb/include/lldb/Host/common/TCPSocket.h 
b/lldb/include/lldb/Host/common/TCPSocket.h
index ca36622691fe9a..ab6bf5ab97cae7 100644
--- a/lldb/include/lldb/Host/common/TCPSocket.h
+++ b/lldb/include/lldb/Host/common/TCPSocket.h
@@ -52,6 +52,8 @@ class TCPSocket : public Socket {
 
   std::string GetRemoteConnectionURI() const override;
 
+  std::string GetListeningConnectionURI() const override;
+
 private:
   TCPSocket(NativeSocket socket, const TCPSocket &listen_socket);
 
diff --git a/lldb/include/lldb/Host/posix/DomainSocket.h 
b/lldb/include/lldb/Host/posix/DomainSocket.h
index d4e0d43ee169c1..d79564cc76dafd 100644
--- a/lldb/include/lldb/Host/posix/DomainSocket.h
+++ b/lldb/include/lldb/Host/posix/DomainSocket.h
@@ -27,6 +27,8 @@ class DomainSocket : public Socket {
 
   std::string GetRemoteConnectionURI() const override;
 
+  std::string GetListeningConnectionURI() const override;
+
 protected:
   DomainSocket(SocketProtocol protocol);
 
diff --git a/lldb/source/Host/common/TCPSocket.cpp 
b/lldb/source/Host/common/TCPSocket.cpp
index 5d863954ee8868..b7bd62ff04855e 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -81,6 +81,12 @@ std::string TCPSocket::GetLocalIPAddress() const {
 socklen_t sock_addr_len = sock_addr.GetMaxLength();
 if (::getsockname(m_socket, sock_addr, &sock_addr_len) == 0)
   return sock_addr.GetIPAddress();
+  } else if (!m_listen_sockets.empty()) {
+SocketAddress sock_addr;
+socklen_t sock_addr_len = sock_addr.GetMaxLength();
+if (::getsockname(m_listen_sockets.begin()->first, sock_addr,
+  &sock_addr_len) == 0)
+  return sock_addr.GetIPAddress();
   }
   return "";
 }
@@ -115,6 +121,15 @@ std::string TCPSocket::GetRemoteConnectionURI() const {
   return "";
 }
 
+std::string TCPSocket::GetListeningConnectionURI() const {
+  if (!m_listen_sockets.empty()) {
+return std::string(llvm::formatv(
+"connection://[{0}]:{1}", GetLocalIPAddress(), GetLocalPortNumber()));
+  }
+
+  return "";
+}
+
 Status TCPSocket::CreateSocket(int domain) {
   Status error;
   if (IsValid())
@@ -176,8 +191,9 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 
   if (host_port->hostname == "*")
 host_port->hostname = "0.0.0.0";
-  std::vector addresses = SocketAddress::GetAddressInfo(
-  host_port->hostname.c_str(), nullptr, AF_UNSPEC, SOCK_STREAM, 
IPPROTO_TCP);
+  std::vector addresses =
+  SocketAddress::GetAddressInfo(host_port->hostname.c_str(), nullptr,
+AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
   for (SocketAddress &address : addresses) {
 int fd =
 Socket::CreateSocket(address.GetFamily(), kType, IPPROTO_TCP, error);
@@ -191,7 +207,7 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 }
 
 SocketAddress listen_address = address;
-if(!listen_address.IsLocalhost())
+if (!listen_address.IsLocalhost())
   listen_address.SetToAnyAddress(address.GetFamily(), host_port->port);
 else
   listen_address.SetPort(host_port->port);
diff --git a/lldb/source/Host/posix/DomainSocket.cpp 
b/lldb/source/Host/posix/DomainSocket.cpp
index 0451834630d33f..beec3c225ecc62 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -86,7 +86,8 @@ Status DomainSocket::Connect(llvm::StringRef name) {
   if (error.Fail())
 return error;
   if (llvm::sys::RetryAfterSignal(-1, ::connect, GetNativeSocket(),

[Lldb-commits] [lldb] [lldb][AIX] Header Parsing for XCOFF Object File in AIX (PR #116338)

2024-12-02 Thread Pavel Labath via lldb-commits

labath wrote:

So, using the llvm structures for parsing (instead of rolling your own) is 
definitely a step in the right direction. However, I don't think you need to 
roll your own parsing either, given that the headers have already been parsed 
in llvm::XCOFFObjectFile. Why can't you just use the header from there?

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


[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-02 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,19 @@
+int main(int argc, char** argv) {
+  struct A {
+struct {
+  int x = 1;
+};
+int y = 2;
+  } a;
+
+  struct B {
+// Anonymous struct inherits another struct.
+struct : public A {
+  int z = 3;
+};
+int w = 4;
+A a;
+  } b;

labath wrote:

Can we avoid running the binary by making this a global variable (and then 
using `target variable` in the test case)?

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


[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-02 Thread Pavel Labath via lldb-commits


@@ -6754,12 +6754,12 @@ size_t TypeSystemClang::GetIndexOfChildMemberWithName(
   llvm::StringRef field_name = field->getName();
   if (field_name.empty()) {
 CompilerType field_type = GetType(field->getType());
+std::vector save_indices = child_indexes;

labath wrote:

So, my preferred solution would be to have this function return a `vector` 
(apparently, there's even a TODO in the header about that (*)). That way you 
can build the result from the bottom up, and only add things to the vector when 
you've found the thing you're searching for and are certain that you're going 
to return successfully. That's going to be slightly slower than passing the 
same vector always (but maybe not slower than making a copy of it 
preemptively). However, I can live with both yours and Michael's solution 
(which I think could still work if you keep the `pop_back` statement so that 
the next iteration starts with a valid state). I'll leave it up to Michael to 
decide, as he spends most of the time looking at this code.

(*) Technically the TODO is about returning a `vector>` of all 
possible matches --  which may be a good idea overall, but I don't think we 
want to do that now.

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


[Lldb-commits] [lldb] [LLDB] Fix crash in TypeSystemClang::GetIndexofChildMemberWithName. (PR #117808)

2024-12-02 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Set return status to Failed when Python command raises uncaught exception (PR #113996)

2024-12-02 Thread Pavel Labath via lldb-commits


@@ -642,6 +649,16 @@ bool 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallCommandObject(
   pfunc(SWIGBridge::ToSWIGWrapper(std::move(debugger)), PythonString(args),
 SWIGBridge::ToSWIGWrapper(exe_ctx_ref_sp), cmd_retobj_arg.obj());
 
+  if (PyErr_Occurred()) {
+py_err_cleaner.~PyErr_Cleaner();

labath wrote:

Fair enough. How about then making a new function (`Expected 
PythonCallable::Call(/*something*/)` which does the right thing, and then 
porting callers you care about to the new API?

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


[Lldb-commits] [lldb] [lldb] fix SourceManagerTestCase freeze (PR #118095)

2024-12-02 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Please dig into why it's failing, remotely or locally whatever you can 
reproduce. I doubt the reason is anything sinister but I'd like to know what it 
is before approving anything.

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


[Lldb-commits] [lldb] [lldb] fix fd leak during lldb testsuite (PR #118093)

2024-12-02 Thread via lldb-commits

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


[Lldb-commits] [lldb] 9a34a4f - [lldb] fix fd leak during lldb testsuite (#118093)

2024-12-02 Thread via lldb-commits

Author: dlav-sc
Date: 2024-12-02T14:51:22+03:00
New Revision: 9a34a4f8d668b72868fde3b6a58bb3a57d72c0c9

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

LOG: [lldb] fix fd leak during lldb testsuite (#118093)

During lldb testing dotest.py opens files to dump testcase results, but
doesn't close them.

This patch makes necessary changes to fix the file descriptors leak.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 8884ef5933ada8..1338d16a9171e2 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -865,13 +865,9 @@ def setUp(self):
 session_file = self.getLogBasenameForCurrentTest() + ".log"
 self.log_files.append(session_file)
 
-# Python 3 doesn't support unbuffered I/O in text mode.  Open buffered.
-self.session = encoded_file.open(session_file, "utf-8", mode="w")
-
 # Optimistically set __errored__, __failed__, __expected__ to False
 # initially.  If the test errored/failed, the session info
-# (self.session) is then dumped into a session specific file for
-# diagnosis.
+# is then dumped into a session specific file for diagnosis.
 self.__cleanup_errored__ = False
 self.__errored__ = False
 self.__failed__ = False
@@ -1235,20 +1231,25 @@ def dumpSessionInfo(self):
 else:
 prefix = "Success"
 
+session_file = self.getLogBasenameForCurrentTest() + ".log"
+
+# Python 3 doesn't support unbuffered I/O in text mode.  Open buffered.
+session = encoded_file.open(session_file, "utf-8", mode="w")
+
 if not self.__unexpected__ and not self.__skipped__:
 for test, traceback in pairs:
 if test is self:
-print(traceback, file=self.session)
+print(traceback, file=session)
 
 import datetime
 
 print(
 "Session info generated @",
 datetime.datetime.now().ctime(),
-file=self.session,
+file=session,
 )
-self.session.close()
-del self.session
+session.close()
+del session
 
 # process the log files
 if prefix != "Success" or lldbtest_config.log_success:



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


[Lldb-commits] [lldb] [lldb][AIX] HostInfoAIX Support (PR #117906)

2024-12-02 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,213 @@
+//===-- HostInfoAIX.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 "lldb/Host/aix/HostInfoAIX.h"
+#include "lldb/Host/Config.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+
+#include "llvm/Support/Threading.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+using namespace lldb_private;
+
+namespace {
+struct HostInfoAIXFields {
+  llvm::once_flag m_distribution_once_flag;
+  std::string m_distribution_id;
+  llvm::once_flag m_os_version_once_flag;
+  llvm::VersionTuple m_os_version;
+};
+} // namespace
+
+static HostInfoAIXFields *g_fields = nullptr;
+
+void HostInfoAIX::Initialize(SharedLibraryDirectoryHelper *helper) {
+  HostInfoPosix::Initialize(helper);
+
+  g_fields = new HostInfoAIXFields();
+}
+
+void HostInfoAIX::Terminate() {
+  assert(g_fields && "Missing call to Initialize?");
+  delete g_fields;
+  g_fields = nullptr;
+  HostInfoBase::Terminate();
+}
+
+llvm::VersionTuple HostInfoAIX::GetOSVersion() {
+  assert(g_fields && "Missing call to Initialize?");
+  llvm::call_once(g_fields->m_os_version_once_flag, []() {
+struct utsname un;
+if (uname(&un) != 0)
+  return;
+
+llvm::StringRef release = un.release;
+// The kernel release string can include a lot of stuff (e.g.
+// 4.9.0-6-amd64). We're only interested in the numbered prefix.
+release = release.substr(0, release.find_first_not_of("0123456789."));
+g_fields->m_os_version.tryParse(release);
+  });
+
+  return g_fields->m_os_version;
+}
+
+std::optional HostInfoAIX::GetOSBuildString() {
+  struct utsname un;
+  ::memset(&un, 0, sizeof(utsname));
+
+  if (uname(&un) < 0)
+return std::nullopt;
+
+  return std::string(un.release);
+}
+
+llvm::StringRef HostInfoAIX::GetDistributionId() {

labath wrote:

I can see that, and I don't blame you for it. To an outsider, it's very hard to 
determine which code is useful, so it's tempting to copy the thing that 
"works". However, as a project maintainer,  I know that we have a lot of tech 
debt around here, and I don't want to make copies of that debt (essentially 
doubling it) if it isn't necessary (and I'm pretty sure you won't need this 
function for anything).

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


[Lldb-commits] [lldb] [lldb][AIX] HostInfoAIX Support (PR #117906)

2024-12-02 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,213 @@
+//===-- HostInfoAIX.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 "lldb/Host/aix/HostInfoAIX.h"
+#include "lldb/Host/Config.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+
+#include "llvm/Support/Threading.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+using namespace lldb_private;
+
+namespace {
+struct HostInfoAIXFields {
+  llvm::once_flag m_distribution_once_flag;
+  std::string m_distribution_id;
+  llvm::once_flag m_os_version_once_flag;
+  llvm::VersionTuple m_os_version;
+};
+} // namespace
+
+static HostInfoAIXFields *g_fields = nullptr;
+
+void HostInfoAIX::Initialize(SharedLibraryDirectoryHelper *helper) {
+  HostInfoPosix::Initialize(helper);
+
+  g_fields = new HostInfoAIXFields();
+}
+
+void HostInfoAIX::Terminate() {
+  assert(g_fields && "Missing call to Initialize?");
+  delete g_fields;
+  g_fields = nullptr;
+  HostInfoBase::Terminate();
+}
+
+llvm::VersionTuple HostInfoAIX::GetOSVersion() {
+  assert(g_fields && "Missing call to Initialize?");
+  llvm::call_once(g_fields->m_os_version_once_flag, []() {
+struct utsname un;
+if (uname(&un) != 0)
+  return;
+
+llvm::StringRef release = un.release;
+// The kernel release string can include a lot of stuff (e.g.
+// 4.9.0-6-amd64). We're only interested in the numbered prefix.
+release = release.substr(0, release.find_first_not_of("0123456789."));
+g_fields->m_os_version.tryParse(release);
+  });
+
+  return g_fields->m_os_version;
+}
+
+std::optional HostInfoAIX::GetOSBuildString() {
+  struct utsname un;
+  ::memset(&un, 0, sizeof(utsname));
+
+  if (uname(&un) < 0)
+return std::nullopt;
+
+  return std::string(un.release);
+}
+
+llvm::StringRef HostInfoAIX::GetDistributionId() {
+  assert(g_fields && "Missing call to Initialize?");
+  // Try to run 'lbs_release -i', and use that response for the distribution
+  // id.
+  llvm::call_once(g_fields->m_distribution_once_flag, []() {
+Log *log = GetLog(LLDBLog::Host);
+LLDB_LOGF(log, "attempting to determine AIX distribution...");
+
+// check if the lsb_release command exists at one of the following paths
+const char *const exe_paths[] = {"/bin/lsb_release",
+ "/usr/bin/lsb_release"};
+
+for (size_t exe_index = 0;
+ exe_index < sizeof(exe_paths) / sizeof(exe_paths[0]); ++exe_index) {
+  const char *const get_distribution_info_exe = exe_paths[exe_index];
+  if (access(get_distribution_info_exe, F_OK)) {
+// this exe doesn't exist, move on to next exe
+LLDB_LOGF(log, "executable doesn't exist: %s",
+  get_distribution_info_exe);
+continue;
+  }
+
+  // execute the distribution-retrieval command, read output
+  std::string get_distribution_id_command(get_distribution_info_exe);
+  get_distribution_id_command += " -i";
+
+  FILE *file = popen(get_distribution_id_command.c_str(), "r");
+  if (!file) {
+LLDB_LOGF(log,
+  "failed to run command: \"%s\", cannot retrieve "
+  "platform information",
+  get_distribution_id_command.c_str());
+break;
+  }
+
+  // retrieve the distribution id string.
+  char distribution_id[256] = {'\0'};
+  if (fgets(distribution_id, sizeof(distribution_id) - 1, file) !=
+  nullptr) {
+LLDB_LOGF(log, "distribution id command returned \"%s\"",
+  distribution_id);
+
+const char *const distributor_id_key = "Distributor ID:\t";
+if (strstr(distribution_id, distributor_id_key)) {
+  // strip newlines
+  std::string id_string(distribution_id + strlen(distributor_id_key));
+  llvm::erase(id_string, '\n');
+
+  // lower case it and convert whitespace to underscores
+  std::transform(
+  id_string.begin(), id_string.end(), id_string.begin(),
+  [](char ch) { return tolower(isspace(ch) ? '_' : ch); });
+
+  g_fields->m_distribution_id = id_string;
+  LLDB_LOGF(log, "distribution id set to \"%s\"",
+g_fields->m_distribution_id.c_str());
+} else {
+  LLDB_LOGF(log, "failed to find \"%s\" field in \"%s\"",
+distributor_id_key, distribution_id);
+}
+  } else {
+LLDB_LOGF(log,
+  "failed to retrieve distribution id, \"%s\" returned no"
+  " lines",
+  get_distribution_id_command.c_str());
+  }
+
+  // clean up the file
+  p

[Lldb-commits] [lldb] [lldb] Increase MAX_ATTEMPTS in connect_to_debug_monitor() (PR #118222)

2024-12-02 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman updated 
https://github.com/llvm/llvm-project/pull/118222

>From bb68e6d523f3e80b991c7370bb00bac2bb9582b6 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sun, 1 Dec 2024 21:35:52 +0400
Subject: [PATCH 1/2] [lldb] Increase MAX_ATTEMPTS in
 connect_to_debug_monitor()

See #118032 for details.
---
 .../lldbsuite/test/tools/lldb-server/gdbremote_testcase.py  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 8c8e4abed0b454..67b07ff4ddd998 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -388,7 +388,7 @@ def connect_to_debug_monitor(self, attach_pid=None):
 # We're using a random port algorithm to try not to collide with other 
ports,
 # and retry a max # times.
 attempts = 0
-MAX_ATTEMPTS = 20
+MAX_ATTEMPTS = 30
 
 while attempts < MAX_ATTEMPTS:
 server = self.launch_debug_monitor(attach_pid=attach_pid)

>From a9a7e4e50d788aeb22bfe94a4ca580e9045882e3 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Mon, 2 Dec 2024 15:17:28 +0400
Subject: [PATCH 2/2] Added an exponential algorithm for the sleep time.
 Reduced MAX_ATTEMPTS to 16. The sleep time will be 3, 3.6, 4.3, ..., 38, 46.
 The total sleep time is 262 + 0.5*MAX_CONNECT_ATTEMPTS*MAX_ATTEMPTS = 342.
 Note the timeout is 600, so the rest time must be enough. Increased the port
 range (12000..2).

---
 .../test/tools/lldb-server/gdbremote_testcase.py  | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 67b07ff4ddd998..04d39bfc74299c 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -185,7 +185,7 @@ def setUpServerLogging(self, is_llgs):
 ]
 
 def get_next_port(self):
-return 12000 + random.randint(0, 3999)
+return 12000 + random.randint(0, 7999)
 
 def reset_test_sequence(self):
 self.test_sequence = GdbRemoteTestSequence(self.logger)
@@ -388,7 +388,8 @@ def connect_to_debug_monitor(self, attach_pid=None):
 # We're using a random port algorithm to try not to collide with other 
ports,
 # and retry a max # times.
 attempts = 0
-MAX_ATTEMPTS = 30
+MAX_ATTEMPTS = 16
+attempt_wait = 3
 
 while attempts < MAX_ATTEMPTS:
 server = self.launch_debug_monitor(attach_pid=attach_pid)
@@ -424,7 +425,8 @@ def connect_to_debug_monitor(self, attach_pid=None):
 
 # And wait a random length of time before next attempt, to avoid
 # collisions.
-time.sleep(random.randint(1, 5))
+time.sleep(attempt_wait)
+attempt_wait *= 1.2
 
 # Now grab a new port number.
 self.port = self.get_next_port()

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


[Lldb-commits] [lldb] [lldb] Increase MAX_ATTEMPTS in connect_to_debug_monitor() (PR #118222)

2024-12-02 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

Updated the patch:
Added an exponential algorithm for the sleep time. Reduced MAX_ATTEMPTS to 16. 
The sleep time will be 3, 3.6, 4.3, ..., 38, 46. 
The total sleep time is 262 + 0.5*MAX_CONNECT_ATTEMPTS*MAX_ATTEMPTS = 342. 
Note the timeout is 600, so the rest time must be enough.
Increased the port range (12000..2).

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


[Lldb-commits] [lldb] [llvm] Modify the localCache API to require an explicit commit on CachedFile… (PR #115331)

2024-12-02 Thread via lldb-commits

anjenner wrote:

Ping for code review please - thank you.

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


[Lldb-commits] [lldb] [lldb] rename fooSynthProvider module (PR #118094)

2024-12-02 Thread via lldb-commits

dlav-sc wrote:

> I'd switch to the (standard) one-process-per-test mode.

It's good you've written about this mode, because I haven't even known that 
lldb testsuite has such option. Could you provide more information how can I 
enable it, please? Is there a corresponding flag for a `dotest.py`?

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


[Lldb-commits] [lldb] [LLDB] Fix error returns in CastToBasicType and CastToEnumType in ValueObject. (PR #117401)

2024-12-02 Thread Pavel Labath via lldb-commits


@@ -3194,16 +3194,19 @@ lldb::ValueObjectSP 
ValueObject::CastToBasicType(CompilerType type) {
   GetCompilerType().IsPointerType() || GetCompilerType().IsNullPtrType();
   bool is_float = GetCompilerType().IsFloat();
   bool is_integer = GetCompilerType().IsInteger();
+  ExecutionContext exe_ctx(GetExecutionContextRef());
 
   if (!type.IsScalarType()) {
-m_error = Status::FromErrorString("target type must be a scalar");
-return GetSP();
+Status error = Status::FromErrorString("target type must be a scalar");
+return ValueObjectConstResult::Create(
+exe_ctx.GetBestExecutionContextScope(), error.Clone());

labath wrote:

```suggestion
return ValueObjectConstResult::Create(
exe_ctx.GetBestExecutionContextScope(), Status::FromErrorString("target 
type must be a scalar"));
```

If you really want to have a variable for this, then you can keep what you have 
and use `std::move` instead of `Clone`, but I think this is better (and I think 
Adrian would agree :) ).

This comment applies throughout the patch.

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


[Lldb-commits] [lldb] [lldb] Added an exponential algorithm for the sleep time in connect_to_debug_monitor() (PR #118222)

2024-12-02 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

Thanks, I suggested something similar in #118032. 

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


[Lldb-commits] [lldb] 1250a1d - [lldb] Update dwim-print to support limited variable expression paths (#117452)

2024-12-02 Thread via lldb-commits

Author: Dave Lee
Date: 2024-12-02T13:55:35-08:00
New Revision: 1250a1db1a378736afda389c94d2846d7a254576

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

LOG: [lldb] Update dwim-print to support limited variable expression paths 
(#117452)

`frame variable` supports nested variable access, which the API calls "variable
expression paths". This change updates `dwim-print` to support a subset of 
supported
variable expression paths.

Consider the expression `a->b`. In C++, the arrow operator can be overloaded, 
and where
that is the case, expression evaluation must be used to evaluate it, not frame 
variable.
Likewise, the subscript operator can be overloaded.

To avoid those cases, this change introduces a limited support for variable 
expression
paths. Use of the dot operator is allowed.

Additionally, this change allows `dwim-print` to directly access children of 
`this` and
`self` (see AllowDirectIVarAccess). This functionality is also provided by the 
same
`GetValueForVariableExpressionPath` method.

rdar://104348908

Added: 
lldb/test/API/commands/dwim-print/main.cpp

Modified: 
lldb/source/Commands/CommandObjectDWIMPrint.cpp
lldb/test/API/commands/dwim-print/Makefile
lldb/test/API/commands/dwim-print/TestDWIMPrint.py

Removed: 
lldb/test/API/commands/dwim-print/main.c



diff  --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp 
b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 62c4e74d853ad1..d4d038d28f6755 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -151,10 +151,24 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 result.SetStatus(eReturnStatusSuccessFinishResult);
   };
 
-  // First, try `expr` as the name of a frame variable.
-  if (frame) {
-auto valobj_sp = frame->FindVariable(ConstString(expr));
-if (valobj_sp && valobj_sp->GetError().Success()) {
+  // First, try `expr` as a _limited_ frame variable expression path: only the
+  // dot operator (`.`) is permitted for this case.
+  //
+  // This is limited to support only unambiguous expression paths. Of note,
+  // expression paths are not attempted if the expression contain either the
+  // arrow operator (`->`) or the subscript operator (`[]`). This is because
+  // both operators can be overloaded in C++, and could result in ambiguity in
+  // how the expression is handled. Additionally, `*` and `&` are not 
supported.
+  const bool try_variable_path =
+  expr.find_first_of("*&->[]") == StringRef::npos;
+  if (frame && try_variable_path) {
+VariableSP var_sp;
+Status status;
+auto valobj_sp = frame->GetValueForVariableExpressionPath(
+expr, eval_options.GetUseDynamic(),
+StackFrame::eExpressionPathOptionsAllowDirectIVarAccess, var_sp,
+status);
+if (valobj_sp && status.Success() && valobj_sp->GetError().Success()) {
   if (!suppress_result) {
 if (auto persisted_valobj = valobj_sp->Persist())
   valobj_sp = persisted_valobj;

diff  --git a/lldb/test/API/commands/dwim-print/Makefile 
b/lldb/test/API/commands/dwim-print/Makefile
index 10495940055b63..8b20bcb050 100644
--- a/lldb/test/API/commands/dwim-print/Makefile
+++ b/lldb/test/API/commands/dwim-print/Makefile
@@ -1,3 +1,3 @@
-C_SOURCES := main.c
+CXX_SOURCES := main.cpp
 
 include Makefile.rules

diff  --git a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py 
b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
index b40924a182e37d..492d49f008a9e4 100644
--- a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
+++ b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
@@ -16,7 +16,7 @@ def _run_cmd(self, cmd: str) -> str:
 self.ci.HandleCommand(cmd, result)
 return result.GetOutput().rstrip()
 
-VAR_IDENT = re.compile(r"(?:\$\d+|\w+) = ")
+VAR_IDENT = re.compile(r"(?:\$\d+|[\w.]+) = ")
 
 def _strip_result_var(self, string: str) -> str:
 """
@@ -121,30 +121,39 @@ def test_empty_expression(self):
 def test_nested_values(self):
 """Test dwim-print with nested values (structs, etc)."""
 self.build()
-lldbutil.run_to_source_breakpoint(self, "break here", 
lldb.SBFileSpec("main.c"))
+lldbutil.run_to_source_breakpoint(
+self, "break here", lldb.SBFileSpec("main.cpp")
+)
 self.runCmd("settings set auto-one-line-summaries false")
 self._expect_cmd(f"dwim-print s", "frame variable")
 self._expect_cmd(f"dwim-print (struct Structure)s", "expression")
 
 def test_summary_strings(self):
-"""Test dwim-print with nested values (structs, etc)."""
+"""Test dwim-print with type summaries."""
 self.build()
-lldbutil.run_to_source_breakpoint(self, "b

[Lldb-commits] [lldb] [lldb] Update dwim-print to support limited variable expression paths (PR #117452)

2024-12-02 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Added an exponential algorithm for the sleep time in connect_to_debug_monitor() (PR #118222)

2024-12-02 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] Bugfix: Not showing the synthetic children of values behind pointers (PR #117755)

2024-12-02 Thread Greg Clayton via lldb-commits

clayborg wrote:

You should be able to debug lldb and step through the code that tries to get 
the synthetic child provider for the type and watch if fail. You can also step 
through the C++ example code from my screen shot and see how it is working to 
see what is going wrong and how the two things differ. 



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


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap port listening mode to allow multiple connections. (PR #116392)

2024-12-02 Thread John Harrison via lldb-commits


@@ -118,6 +124,15 @@ std::string TCPSocket::GetRemoteConnectionURI() const {
   return "";
 }
 
+std::string TCPSocket::GetListeningConnectionURI() const {

ashgti wrote:

Split this into its own PR https://github.com/llvm/llvm-project/pull/118330

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


[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)

2024-12-02 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,130 @@
+//===-- NativeProcessAIX.h -- -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_NativeProcessAIX_H_
+#define liblldb_NativeProcessAIX_H_
+
+#include 
+#include 
+
+#include "lldb/Host/Debug.h"
+#include "lldb/Host/HostThread.h"
+#include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/lldb-types.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+#include "NativeThreadAIX.h"
+#include "Plugins/Process/Utility/NativeProcessSoftwareSingleStep.h"
+#include "lldb/Host/common/NativeProcessProtocol.h"
+
+namespace lldb_private {
+class Status;
+class Scalar;

labath wrote:

Remove (scalar is unused, and I think its better replace the Status forward 
decl with an actual include, as some of the files you are including will 
include it anyway).

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


[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)

2024-12-02 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,248 @@
+//===-- NativeProcessAIX.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 "NativeProcessAIX.h"
+#include "NativeThreadAIX.h"

labath wrote:

There's no file like this. Can you make sure this at least compiles?

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


[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)

2024-12-02 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,130 @@
+//===-- NativeProcessAIX.h -- -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_NativeProcessAIX_H_
+#define liblldb_NativeProcessAIX_H_
+
+#include 
+#include 
+
+#include "lldb/Host/Debug.h"
+#include "lldb/Host/HostThread.h"
+#include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/lldb-types.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+#include "NativeThreadAIX.h"
+#include "Plugins/Process/Utility/NativeProcessSoftwareSingleStep.h"
+#include "lldb/Host/common/NativeProcessProtocol.h"

labath wrote:

```suggestion
#include 
#include "lldb/Host/Debug.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/lldb-types.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "Plugins/Process/Utility/NativeProcessSoftwareSingleStep.h"
#include "lldb/Host/common/NativeProcessProtocol.h"
```

I've grouped the includes into a single block and removed those that are 
obviously unused (for now, at least). You'll need to run clang-format on this 
afterwards.

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


[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)

2024-12-02 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,130 @@
+//===-- NativeProcessAIX.h -- -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_NativeProcessAIX_H_
+#define liblldb_NativeProcessAIX_H_
+
+#include 
+#include 
+
+#include "lldb/Host/Debug.h"
+#include "lldb/Host/HostThread.h"
+#include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/lldb-types.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+#include "NativeThreadAIX.h"
+#include "Plugins/Process/Utility/NativeProcessSoftwareSingleStep.h"
+#include "lldb/Host/common/NativeProcessProtocol.h"
+
+namespace lldb_private {
+class Status;
+class Scalar;
+
+namespace process_aix {
+/// \class NativeProcessAIX
+/// Manages communication with the inferior (debugee) process.
+///
+/// Upon construction, this class prepares and launches an inferior process
+/// for debugging.
+///
+/// Changes in the inferior process state are broadcasted.
+class NativeProcessAIX : public NativeProcessProtocol,
+ private NativeProcessSoftwareSingleStep {
+public:
+  class Manager : public NativeProcessProtocol::Manager {
+  public:
+Manager(MainLoop &mainloop);
+
+llvm::Expected>
+Launch(ProcessLaunchInfo &launch_info,
+   NativeDelegate &native_delegate) override;
+
+llvm::Expected>
+Attach(lldb::pid_t pid, NativeDelegate &native_delegate) override;
+
+Extension GetSupportedExtensions() const override;
+
+void AddProcess(NativeProcessAIX &process) { m_processes.insert(&process); 
}
+
+void RemoveProcess(NativeProcessAIX &process) {
+  m_processes.erase(&process);
+}
+
+// Collect an event for the given tid, waiting for it if necessary.
+void CollectThread(::pid_t tid);
+
+  private:
+MainLoop::SignalHandleUP m_sigchld_handle;
+
+llvm::SmallPtrSet m_processes;
+
+void SigchldHandler();
+  };
+
+  // NativeProcessProtocol Interface
+
+  ~NativeProcessAIX() override { m_manager.RemoveProcess(*this); }
+
+  Status Resume(const ResumeActionList &resume_actions) override;
+
+  Status Halt() override;
+
+  Status Detach() override;
+
+  Status Signal(int signo) override;
+
+  Status Interrupt() override;
+
+  Status Kill() override;
+
+  const ArchSpec &GetArchitecture() const override { return m_arch; }
+
+  Status SetBreakpoint(lldb::addr_t addr, uint32_t size,
+   bool hardware) override;
+
+  Status RemoveBreakpoint(lldb::addr_t addr, bool hardware = false) override;
+
+  Status GetFileLoadAddress(const llvm::StringRef &file_name,
+lldb::addr_t &load_addr) override;
+
+  static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr,
+  void *data = nullptr, size_t data_size = 0,
+  long *result = nullptr);
+
+  // Wrapper for ptrace to catch errors and log calls. Note that ptrace sets
+
+private:
+  Manager &m_manager;
+  /*MainLoop::SignalHandleUP m_sigchld_handle;*/

labath wrote:

LLVM doesn't generally use C style comments 
. I'd just 
delete this for now.

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


[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)

2024-12-02 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

I think we can make some progress here, but I don't think we'll get far without 
ProcessLauncher support. At some point, not too far from now, I'm going to 
start asking questions like "which tests does this fix", and I don't think 
you'll be able to run any of them without a process launcher.

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


[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)

2024-12-02 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,130 @@
+//===-- NativeProcessAIX.h -- -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_NativeProcessAIX_H_
+#define liblldb_NativeProcessAIX_H_
+
+#include 
+#include 
+
+#include "lldb/Host/Debug.h"
+#include "lldb/Host/HostThread.h"
+#include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/lldb-types.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+#include "NativeThreadAIX.h"
+#include "Plugins/Process/Utility/NativeProcessSoftwareSingleStep.h"
+#include "lldb/Host/common/NativeProcessProtocol.h"
+
+namespace lldb_private {
+class Status;
+class Scalar;
+
+namespace process_aix {
+/// \class NativeProcessAIX
+/// Manages communication with the inferior (debugee) process.
+///
+/// Upon construction, this class prepares and launches an inferior process
+/// for debugging.
+///
+/// Changes in the inferior process state are broadcasted.
+class NativeProcessAIX : public NativeProcessProtocol,
+ private NativeProcessSoftwareSingleStep {
+public:
+  class Manager : public NativeProcessProtocol::Manager {
+  public:
+Manager(MainLoop &mainloop);
+
+llvm::Expected>
+Launch(ProcessLaunchInfo &launch_info,
+   NativeDelegate &native_delegate) override;
+
+llvm::Expected>
+Attach(lldb::pid_t pid, NativeDelegate &native_delegate) override;
+
+Extension GetSupportedExtensions() const override;
+
+void AddProcess(NativeProcessAIX &process) { m_processes.insert(&process); 
}
+
+void RemoveProcess(NativeProcessAIX &process) {
+  m_processes.erase(&process);
+}
+
+// Collect an event for the given tid, waiting for it if necessary.
+void CollectThread(::pid_t tid);
+
+  private:
+MainLoop::SignalHandleUP m_sigchld_handle;
+
+llvm::SmallPtrSet m_processes;
+
+void SigchldHandler();
+  };
+
+  // NativeProcessProtocol Interface
+
+  ~NativeProcessAIX() override { m_manager.RemoveProcess(*this); }
+
+  Status Resume(const ResumeActionList &resume_actions) override;
+
+  Status Halt() override;
+
+  Status Detach() override;
+
+  Status Signal(int signo) override;
+
+  Status Interrupt() override;
+
+  Status Kill() override;
+
+  const ArchSpec &GetArchitecture() const override { return m_arch; }
+
+  Status SetBreakpoint(lldb::addr_t addr, uint32_t size,
+   bool hardware) override;
+
+  Status RemoveBreakpoint(lldb::addr_t addr, bool hardware = false) override;
+
+  Status GetFileLoadAddress(const llvm::StringRef &file_name,
+lldb::addr_t &load_addr) override;
+
+  static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr,
+  void *data = nullptr, size_t data_size = 0,
+  long *result = nullptr);

labath wrote:

```suggestion
  static llvm::Expected PtraceWrapper(int req, lldb::pid_t pid, void 
*addr = nullptr,
  void *data = nullptr, size_t data_size = 0);
```

This is /probably/ what the modern version of the API would look like. It's 
hard to say as the function is not implemented. It'd be better to leave this 
function out for (and stub out the callers) or at least implement the parts 
that are already being used (attach/detach, it seems).

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


[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)

2024-12-02 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,248 @@
+//===-- NativeProcessAIX.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 "NativeProcessAIX.h"
+#include "NativeThreadAIX.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostProcess.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/State.h"
+#include "lldb/Utility/Status.h"
+#include "lldb/Utility/StringExtractor.h"
+#include "llvm/Support/Errno.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 

labath wrote:

```suggestion
#include "lldb/Host/Host.h"
#include "lldb/Host/ProcessLaunchInfo.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/State.h"
#include "lldb/Utility/Status.h"
#include "llvm/Support/Errno.h"
#include "llvm/Support/Error.h"
#include 
#include 
#include 
#include 
#include 
#include 
```

(removed unused includes)

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


[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)

2024-12-02 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)

2024-12-02 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,130 @@
+//===-- NativeProcessAIX.h -- -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_NativeProcessAIX_H_
+#define liblldb_NativeProcessAIX_H_
+
+#include 
+#include 
+
+#include "lldb/Host/Debug.h"
+#include "lldb/Host/HostThread.h"
+#include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/lldb-types.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+#include "NativeThreadAIX.h"
+#include "Plugins/Process/Utility/NativeProcessSoftwareSingleStep.h"
+#include "lldb/Host/common/NativeProcessProtocol.h"
+
+namespace lldb_private {
+class Status;
+class Scalar;
+
+namespace process_aix {
+/// \class NativeProcessAIX
+/// Manages communication with the inferior (debugee) process.
+///
+/// Upon construction, this class prepares and launches an inferior process
+/// for debugging.
+///
+/// Changes in the inferior process state are broadcasted.
+class NativeProcessAIX : public NativeProcessProtocol,
+ private NativeProcessSoftwareSingleStep {
+public:
+  class Manager : public NativeProcessProtocol::Manager {
+  public:
+Manager(MainLoop &mainloop);
+
+llvm::Expected>
+Launch(ProcessLaunchInfo &launch_info,
+   NativeDelegate &native_delegate) override;
+
+llvm::Expected>
+Attach(lldb::pid_t pid, NativeDelegate &native_delegate) override;
+
+Extension GetSupportedExtensions() const override;
+
+void AddProcess(NativeProcessAIX &process) { m_processes.insert(&process); 
}
+
+void RemoveProcess(NativeProcessAIX &process) {
+  m_processes.erase(&process);
+}
+
+// Collect an event for the given tid, waiting for it if necessary.
+void CollectThread(::pid_t tid);
+
+  private:
+MainLoop::SignalHandleUP m_sigchld_handle;
+
+llvm::SmallPtrSet m_processes;
+
+void SigchldHandler();
+  };
+
+  // NativeProcessProtocol Interface
+
+  ~NativeProcessAIX() override { m_manager.RemoveProcess(*this); }
+
+  Status Resume(const ResumeActionList &resume_actions) override;
+
+  Status Halt() override;
+
+  Status Detach() override;
+
+  Status Signal(int signo) override;
+
+  Status Interrupt() override;
+
+  Status Kill() override;
+
+  const ArchSpec &GetArchitecture() const override { return m_arch; }
+
+  Status SetBreakpoint(lldb::addr_t addr, uint32_t size,
+   bool hardware) override;
+
+  Status RemoveBreakpoint(lldb::addr_t addr, bool hardware = false) override;
+
+  Status GetFileLoadAddress(const llvm::StringRef &file_name,
+lldb::addr_t &load_addr) override;
+
+  static Status PtraceWrapper(int req, lldb::pid_t pid, void *addr = nullptr,
+  void *data = nullptr, size_t data_size = 0,
+  long *result = nullptr);
+
+  // Wrapper for ptrace to catch errors and log calls. Note that ptrace sets

labath wrote:

This looks wrong.

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


[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)

2024-12-02 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,248 @@
+//===-- NativeProcessAIX.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 "NativeProcessAIX.h"
+#include "NativeThreadAIX.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostProcess.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/State.h"
+#include "lldb/Utility/Status.h"
+#include "lldb/Utility/StringExtractor.h"
+#include "llvm/Support/Errno.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_aix;
+using namespace llvm;
+
+static constexpr unsigned k_ptrace_word_size = sizeof(void *);
+static_assert(sizeof(long) >= k_ptrace_word_size,
+  "Size of long must be larger than ptrace word size");
+
+// Simple helper function to ensure flags are enabled on the given file
+// descriptor.
+static Status EnsureFDFlags(int fd, int flags) {
+  Status error;
+
+  int status = fcntl(fd, F_GETFL);
+  if (status == -1) {
+error = Status::FromErrno();
+return error;
+  }
+
+  if (fcntl(fd, F_SETFL, status | flags) == -1) {
+error = Status::FromErrno();
+return error;
+  }
+
+  return error;
+}
+
+NativeProcessAIX::Manager::Manager(MainLoop &mainloop)
+: NativeProcessProtocol::Manager(mainloop) {
+  Status status;
+  m_sigchld_handle = mainloop.RegisterSignal(
+  SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, status);
+  assert(m_sigchld_handle && status.Success());
+}
+
+// Public Static Methods
+
+llvm::Expected>
+NativeProcessAIX::Manager::Launch(ProcessLaunchInfo &launch_info,
+  NativeDelegate &native_delegate) {
+  Log *log = GetLog(POSIXLog::Process);
+
+  Status status;
+  ::pid_t pid = ProcessLauncherPosixFork()
+.LaunchProcess(launch_info, status)
+.GetProcessId();
+  LLDB_LOG(log, "pid = {0:x}", pid);
+  if (status.Fail()) {
+LLDB_LOG(log, "failed to launch process: {0}", status);
+return status.ToError();
+  }
+
+  // Wait for the child process to trap on its call to execve.
+  int wstatus = 0;
+  ::pid_t wpid = llvm::sys::RetryAfterSignal(-1, ::waitpid, pid, &wstatus, 0);
+  assert(wpid == pid);
+  UNUSED_IF_ASSERT_DISABLED(wpid);
+  if (!WIFSTOPPED(wstatus)) {
+LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}",
+ WaitStatus::Decode(wstatus));
+return llvm::make_error("Could not sync with inferior 
process",
+ llvm::inconvertibleErrorCode());
+  }
+  LLDB_LOG(log, "inferior started, now in stopped state");
+
+  ProcessInstanceInfo Info;
+  if (!Host::GetProcessInfo(pid, Info)) {
+return llvm::make_error("Cannot get process architectrue",
+ llvm::inconvertibleErrorCode());
+  }
+
+  // Set the architecture to the exe architecture.
+  LLDB_LOG(log, "pid = {0}, detected architecture {1}", pid,
+   Info.GetArchitecture().GetArchitectureName());
+
+  return std::unique_ptr(new NativeProcessAIX(
+  pid, launch_info.GetPTY().ReleasePrimaryFileDescriptor(), 
native_delegate,
+  Info.GetArchitecture(), *this, {pid}));
+}
+
+llvm::Expected>
+NativeProcessAIX::Manager::Attach(
+lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate) {
+  Log *log = GetLog(POSIXLog::Process);
+  LLDB_LOG(log, "pid = {0:x}", pid);
+
+  ProcessInstanceInfo Info;
+  if (!Host::GetProcessInfo(pid, Info)) {
+return llvm::make_error("Cannot get process architectrue",
+ llvm::inconvertibleErrorCode());
+  }
+  auto tids_or = NativeProcessAIX::Attach(pid);
+  if (!tids_or)
+return tids_or.takeError();
+
+  return std::unique_ptr(new NativeProcessAIX(
+  pid, -1, native_delegate, Info.GetArchitecture(), *this, *tids_or));
+}
+
+NativeProcessAIX::Extension
+NativeProcessAIX::Manager::GetSupportedExtensions() const {
+  NativeProcessAIX::Extension supported =
+  Extension::multiprocess | Extension::fork | Extension::vfork |
+  Extension::pass_signals | Extension::auxv | Extension::libraries_svr4 |
+  Extension::siginfo_read;

labath wrote:

Better set this to empty. You can add extension support as you implement it.

https://github.com/llvm/llvm-project/pull/118160
__

[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)

2024-12-02 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,130 @@
+//===-- NativeProcessAIX.h -- -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_NativeProcessAIX_H_

labath wrote:

Use the new style header guard.

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


[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)

2024-12-02 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,130 @@
+//===-- NativeProcessAIX.h -- -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef liblldb_NativeProcessAIX_H_
+#define liblldb_NativeProcessAIX_H_
+
+#include 
+#include 
+
+#include "lldb/Host/Debug.h"
+#include "lldb/Host/HostThread.h"
+#include "lldb/Target/MemoryRegionInfo.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/lldb-types.h"
+#include "llvm/ADT/SmallPtrSet.h"
+
+#include "NativeThreadAIX.h"
+#include "Plugins/Process/Utility/NativeProcessSoftwareSingleStep.h"
+#include "lldb/Host/common/NativeProcessProtocol.h"
+
+namespace lldb_private {
+class Status;
+class Scalar;
+
+namespace process_aix {
+/// \class NativeProcessAIX
+/// Manages communication with the inferior (debugee) process.
+///
+/// Upon construction, this class prepares and launches an inferior process
+/// for debugging.
+///
+/// Changes in the inferior process state are broadcasted.
+class NativeProcessAIX : public NativeProcessProtocol,
+ private NativeProcessSoftwareSingleStep {

labath wrote:

Does your architecture actually need software single stepping?

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


[Lldb-commits] [lldb] [lldb] Increase MAX_ATTEMPTS in connect_to_debug_monitor() (PR #118222)

2024-12-02 Thread Pavel Labath via lldb-commits

labath wrote:

20 attempts  is already more than what I would consider reasonable. Increasing 
it doesn't sound like a good idea. If the problem is lingering sockets, then I 
think a better approach is to slow down the rate of socket creation, not churn 
out more of them.

While this code tries to back off, it doesn't implement the (standard?) 
*exponential* backoff algorithm. I think that's important, as without it, it 
just ends up churning out more and more connections at a relative fast rate 
(`time.sleep(random.randint(1, 5))` gives you an average of 3s, so this may 
even be faster than "running a test" -- which also generates a new socket. And 
since this happens a few times, I wouldn't be surprised if that's during the 
times that the random generator generates a locally-lower-than-average sequence 
of random numbers). 

So, the thing I'd do is use a proper exponential algorithm and *reduce* the 
retry count (so that the total wait time ends up being slightly more than what 
it is now), and also increase the range of ports that we're picking from (I 
don't know how the `12000 + random.randint(0, 3999)` thingy was chosen, but I 
think we could increase that any issues).

(Of course, a much better solution would be to either let lldb-server pick a 
free port (and communicate it back to the test somehow) or to reuse the socket 
multiplexing approach we (you) recently implemented. That may not work for all 
tests (we still need to test the user-provided-port scenario somehow), but 99% 
of the tests don't care about the connection method, o if we can solve the 
problem for the majority of tests, then this alleviates the pressure on the 
minority that does need it.)

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


[Lldb-commits] [lldb] [lldb] Added an exponential algorithm for the sleep time in connect_to_debug_monitor() (PR #118222)

2024-12-02 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] [lldb] rename fooSynthProvider module (PR #118094)

2024-12-02 Thread Pavel Labath via lldb-commits

labath wrote:

I don't run remote tests these days, but it sounds like you need to invoke the 
tests through lit rather than running tests directly. Here's some description 
of this: 
https://github.com/llvm/llvm-project/blob/4930f69b78e215c60eb53e25596599c2f98b6564/lldb/test/API/lit.cfg.py#L292


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


[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

2024-12-02 Thread John Harrison via lldb-commits

https://github.com/ashgti created 
https://github.com/llvm/llvm-project/pull/118330

This is most useful if you are listening on an address like 'localhost:0' and 
want to know the resolved ip + port of the socket listener.

>From c3226b620bc8f745b92b3aca7b189803a24db788 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Mon, 2 Dec 2024 08:29:01 -0800
Subject: [PATCH] [lldb] For a host socket, add a method to print the listening
 address.

This is most useful if you are listening on an address like 'localhost:0' and 
want to know the resolved ip + port of the socket listeniner.
---
 lldb/include/lldb/Host/Socket.h |  3 ++
 lldb/include/lldb/Host/common/TCPSocket.h   |  2 +
 lldb/include/lldb/Host/posix/DomainSocket.h |  2 +
 lldb/source/Host/common/TCPSocket.cpp   | 22 +++--
 lldb/source/Host/posix/DomainSocket.cpp | 17 ++-
 lldb/unittests/Host/SocketTest.cpp  | 51 ++---
 6 files changed, 86 insertions(+), 11 deletions(-)

diff --git a/lldb/include/lldb/Host/Socket.h b/lldb/include/lldb/Host/Socket.h
index e98797b36c8a5d..c937e0c02ff19e 100644
--- a/lldb/include/lldb/Host/Socket.h
+++ b/lldb/include/lldb/Host/Socket.h
@@ -151,6 +151,9 @@ class Socket : public IOObject {
   // If this Socket is connected then return the URI used to connect.
   virtual std::string GetRemoteConnectionURI() const { return ""; };
 
+  // If the Socket is listening then return the URI for clients to connect.
+  virtual std::string GetListeningConnectionURI() const { return ""; }
+
 protected:
   Socket(SocketProtocol protocol, bool should_close);
 
diff --git a/lldb/include/lldb/Host/common/TCPSocket.h 
b/lldb/include/lldb/Host/common/TCPSocket.h
index ca36622691fe9a..ab6bf5ab97cae7 100644
--- a/lldb/include/lldb/Host/common/TCPSocket.h
+++ b/lldb/include/lldb/Host/common/TCPSocket.h
@@ -52,6 +52,8 @@ class TCPSocket : public Socket {
 
   std::string GetRemoteConnectionURI() const override;
 
+  std::string GetListeningConnectionURI() const override;
+
 private:
   TCPSocket(NativeSocket socket, const TCPSocket &listen_socket);
 
diff --git a/lldb/include/lldb/Host/posix/DomainSocket.h 
b/lldb/include/lldb/Host/posix/DomainSocket.h
index d4e0d43ee169c1..d79564cc76dafd 100644
--- a/lldb/include/lldb/Host/posix/DomainSocket.h
+++ b/lldb/include/lldb/Host/posix/DomainSocket.h
@@ -27,6 +27,8 @@ class DomainSocket : public Socket {
 
   std::string GetRemoteConnectionURI() const override;
 
+  std::string GetListeningConnectionURI() const override;
+
 protected:
   DomainSocket(SocketProtocol protocol);
 
diff --git a/lldb/source/Host/common/TCPSocket.cpp 
b/lldb/source/Host/common/TCPSocket.cpp
index 5d863954ee8868..b7bd62ff04855e 100644
--- a/lldb/source/Host/common/TCPSocket.cpp
+++ b/lldb/source/Host/common/TCPSocket.cpp
@@ -81,6 +81,12 @@ std::string TCPSocket::GetLocalIPAddress() const {
 socklen_t sock_addr_len = sock_addr.GetMaxLength();
 if (::getsockname(m_socket, sock_addr, &sock_addr_len) == 0)
   return sock_addr.GetIPAddress();
+  } else if (!m_listen_sockets.empty()) {
+SocketAddress sock_addr;
+socklen_t sock_addr_len = sock_addr.GetMaxLength();
+if (::getsockname(m_listen_sockets.begin()->first, sock_addr,
+  &sock_addr_len) == 0)
+  return sock_addr.GetIPAddress();
   }
   return "";
 }
@@ -115,6 +121,15 @@ std::string TCPSocket::GetRemoteConnectionURI() const {
   return "";
 }
 
+std::string TCPSocket::GetListeningConnectionURI() const {
+  if (!m_listen_sockets.empty()) {
+return std::string(llvm::formatv(
+"connection://[{0}]:{1}", GetLocalIPAddress(), GetLocalPortNumber()));
+  }
+
+  return "";
+}
+
 Status TCPSocket::CreateSocket(int domain) {
   Status error;
   if (IsValid())
@@ -176,8 +191,9 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 
   if (host_port->hostname == "*")
 host_port->hostname = "0.0.0.0";
-  std::vector addresses = SocketAddress::GetAddressInfo(
-  host_port->hostname.c_str(), nullptr, AF_UNSPEC, SOCK_STREAM, 
IPPROTO_TCP);
+  std::vector addresses =
+  SocketAddress::GetAddressInfo(host_port->hostname.c_str(), nullptr,
+AF_UNSPEC, SOCK_STREAM, IPPROTO_TCP);
   for (SocketAddress &address : addresses) {
 int fd =
 Socket::CreateSocket(address.GetFamily(), kType, IPPROTO_TCP, error);
@@ -191,7 +207,7 @@ Status TCPSocket::Listen(llvm::StringRef name, int backlog) 
{
 }
 
 SocketAddress listen_address = address;
-if(!listen_address.IsLocalhost())
+if (!listen_address.IsLocalhost())
   listen_address.SetToAnyAddress(address.GetFamily(), host_port->port);
 else
   listen_address.SetPort(host_port->port);
diff --git a/lldb/source/Host/posix/DomainSocket.cpp 
b/lldb/source/Host/posix/DomainSocket.cpp
index 0451834630d33f..beec3c225ecc62 100644
--- a/lldb/source/Host/posix/DomainSocket.cpp
+++ b/lldb/source/Host/posix/DomainSocket.cpp
@@ -86,7 +86,8 @@ Status DomainSocket::Conn

[Lldb-commits] [lldb] [lldb] For a host socket, add a method to print the listening address. (PR #118330)

2024-12-02 Thread John Harrison via lldb-commits

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


[Lldb-commits] [lldb] Bugfix: Not showing the synthetic children of values behind pointers (PR #117755)

2024-12-02 Thread Greg Clayton via lldb-commits

clayborg wrote:

https://github.com/user-attachments/assets/b7dbb80c-5f7d-4dd8-a0db-d0b8fe10cf21";>

Still works inside of a structure. Anything else I can try?

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


[Lldb-commits] [lldb] [lldb] Update dwim-print to support limited variable expression paths (PR #117452)

2024-12-02 Thread Dave Lee via lldb-commits


@@ -154,5 +163,25 @@ def test_preserves_persistent_variables(self):
 def test_missing_type(self):
 """The expected output of po opaque is its address (no error)"""
 self.build()
-lldbutil.run_to_source_breakpoint(self, "break here", 
lldb.SBFileSpec("main.c"))
+lldbutil.run_to_source_breakpoint(
+self, "break here", lldb.SBFileSpec("main.cpp")
+)
 self.expect("dwim-print -O -- opaque", substrs=["0x"])
+
+def test_variable_expression_path(self):
+"""Test dwim-print supports certain variable expression paths."""
+self.build()
+lldbutil.run_to_source_breakpoint(
+self, "break here", lldb.SBFileSpec("main.cpp")
+)
+self.runCmd("settings set auto-one-line-summaries false")
+self._expect_cmd("dwim-print w.s", "frame variable")
+self._expect_cmd("dwim-print wp->s", "expression")

kastiglione wrote:

there are tests for those in `test_variable_paths`

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


[Lldb-commits] [lldb] [lldb] Expose discontinuous functions through SBFunction::GetRanges (PR #117532)

2024-12-02 Thread Alex Langford via lldb-commits

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

Overall LGTM. It'd be nice if the test could be architecture independent but I 
understand if that's difficult or not possible right now.

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


[Lldb-commits] [lldb] [lldb] Expose discontinuous functions through SBFunction::GetRanges (PR #117532)

2024-12-02 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Update dwim-print to support limited variable expression paths (PR #117452)

2024-12-02 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/117452

>From cce676f2e8e0ed7a81ae1fa78082765cb698de85 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Sat, 23 Nov 2024 14:37:10 -0800
Subject: [PATCH 1/3] [lldb] Update dwim-print to support limited variable
 expression paths

`frame variable` supports nested variable access, which the API calls "variable
expression paths". This change updates `dwim-print` to support a subset of 
supported
variable expression paths.

Consider the expression `a->b`. In C++, the arrow operator can be overloaded, 
and where
that is the case, expression evaluation must be used to evaluate it, not frame 
variable.
Likewise, the subscript operator can be overloaded.

To avoid those cases, this change introduces a limited support for variable 
expression
paths. Use of the dot operator is allowed.

Additionally, this change allows `dwim-print` to directly access children of 
`this` and
`self` (see AllowDirectIVarAccess). This functionality is also provided by the 
same
`GetValueForVariableExpressionPath` method.

rdar://104348908
---
 .../Commands/CommandObjectDWIMPrint.cpp   | 21 +++--
 lldb/test/API/commands/dwim-print/Makefile|  2 +-
 .../API/commands/dwim-print/TestDWIMPrint.py  | 43 ---
 lldb/test/API/commands/dwim-print/main.c  | 14 --
 lldb/test/API/commands/dwim-print/main.cpp| 22 ++
 5 files changed, 76 insertions(+), 26 deletions(-)
 delete mode 100644 lldb/test/API/commands/dwim-print/main.c
 create mode 100644 lldb/test/API/commands/dwim-print/main.cpp

diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp 
b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 62c4e74d853ad1..842ff6e1466d63 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -151,10 +151,23 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 result.SetStatus(eReturnStatusSuccessFinishResult);
   };
 
-  // First, try `expr` as the name of a frame variable.
-  if (frame) {
-auto valobj_sp = frame->FindVariable(ConstString(expr));
-if (valobj_sp && valobj_sp->GetError().Success()) {
+  // First, try `expr` as a _limited_ frame variable expression path: only the
+  // dot operator (`.`) is permitted for this case.
+  //
+  // This is limited to support only unambiguous expression paths. Of note,
+  // expression paths are not attempted if the expression contain either the
+  // arrow operator (`->`) or the subscript operator (`[]`). This is because
+  // both operators can be overloaded in C++, and could result in ambiguity in
+  // how the expression is handled. Additionally, `*` and `&` are not 
supported.
+  bool try_variable_path = expr.find_first_of("*&->[]") == StringRef::npos;
+  if (frame && try_variable_path) {
+Status status;
+VariableSP var_sp;
+auto valobj_sp = frame->GetValueForVariableExpressionPath(
+expr, eDynamicDontRunTarget,
+StackFrame::eExpressionPathOptionsAllowDirectIVarAccess, var_sp,
+status);
+if (valobj_sp && status.Success() && valobj_sp->GetError().Success()) {
   if (!suppress_result) {
 if (auto persisted_valobj = valobj_sp->Persist())
   valobj_sp = persisted_valobj;
diff --git a/lldb/test/API/commands/dwim-print/Makefile 
b/lldb/test/API/commands/dwim-print/Makefile
index 10495940055b63..8b20bcb050 100644
--- a/lldb/test/API/commands/dwim-print/Makefile
+++ b/lldb/test/API/commands/dwim-print/Makefile
@@ -1,3 +1,3 @@
-C_SOURCES := main.c
+CXX_SOURCES := main.cpp
 
 include Makefile.rules
diff --git a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py 
b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
index b40924a182e37d..492d49f008a9e4 100644
--- a/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
+++ b/lldb/test/API/commands/dwim-print/TestDWIMPrint.py
@@ -16,7 +16,7 @@ def _run_cmd(self, cmd: str) -> str:
 self.ci.HandleCommand(cmd, result)
 return result.GetOutput().rstrip()
 
-VAR_IDENT = re.compile(r"(?:\$\d+|\w+) = ")
+VAR_IDENT = re.compile(r"(?:\$\d+|[\w.]+) = ")
 
 def _strip_result_var(self, string: str) -> str:
 """
@@ -121,30 +121,39 @@ def test_empty_expression(self):
 def test_nested_values(self):
 """Test dwim-print with nested values (structs, etc)."""
 self.build()
-lldbutil.run_to_source_breakpoint(self, "break here", 
lldb.SBFileSpec("main.c"))
+lldbutil.run_to_source_breakpoint(
+self, "break here", lldb.SBFileSpec("main.cpp")
+)
 self.runCmd("settings set auto-one-line-summaries false")
 self._expect_cmd(f"dwim-print s", "frame variable")
 self._expect_cmd(f"dwim-print (struct Structure)s", "expression")
 
 def test_summary_strings(self):
-"""Test dwim-print with nested values (structs, etc)."""
+"""Test dwim-print with type summaries."""
 self.build()
-lldbutil

[Lldb-commits] [lldb] [lldb] Update dwim-print to support limited variable expression paths (PR #117452)

2024-12-02 Thread Dave Lee via lldb-commits


@@ -151,10 +151,23 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 result.SetStatus(eReturnStatusSuccessFinishResult);
   };
 
-  // First, try `expr` as the name of a frame variable.
-  if (frame) {
-auto valobj_sp = frame->FindVariable(ConstString(expr));
-if (valobj_sp && valobj_sp->GetError().Success()) {
+  // First, try `expr` as a _limited_ frame variable expression path: only the
+  // dot operator (`.`) is permitted for this case.
+  //
+  // This is limited to support only unambiguous expression paths. Of note,
+  // expression paths are not attempted if the expression contain either the
+  // arrow operator (`->`) or the subscript operator (`[]`). This is because
+  // both operators can be overloaded in C++, and could result in ambiguity in
+  // how the expression is handled. Additionally, `*` and `&` are not 
supported.
+  bool try_variable_path = expr.find_first_of("*&->[]") == StringRef::npos;

kastiglione wrote:

done

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


[Lldb-commits] [lldb] a951e76 - [lldb] Added an exponential algorithm for the sleep time in connect_to_debug_monitor() (#118222)

2024-12-02 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2024-12-02T20:51:44+04:00
New Revision: a951e76fbed642dbe3f51965d17ca566be586cc5

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

LOG: [lldb] Added an exponential algorithm for the sleep time in 
connect_to_debug_monitor() (#118222)

Reduced MAX_ATTEMPTS to 10.
The sleep time will be 3, 3.6, 4.3, ..., 13, 15.
The total sleep time is 78 + 0.5 * MAX_CONNECT_ATTEMPTS * MAX_ATTEMPTS = 128.
Note the timeout is 600, so the rest time must be enough.
Increased the port range (12000..2).

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 8c8e4abed0b454..d6cb68f55bf296 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -185,7 +185,7 @@ def setUpServerLogging(self, is_llgs):
 ]
 
 def get_next_port(self):
-return 12000 + random.randint(0, 3999)
+return 12000 + random.randint(0, 7999)
 
 def reset_test_sequence(self):
 self.test_sequence = GdbRemoteTestSequence(self.logger)
@@ -388,7 +388,8 @@ def connect_to_debug_monitor(self, attach_pid=None):
 # We're using a random port algorithm to try not to collide with other 
ports,
 # and retry a max # times.
 attempts = 0
-MAX_ATTEMPTS = 20
+MAX_ATTEMPTS = 10
+attempt_wait = 3
 
 while attempts < MAX_ATTEMPTS:
 server = self.launch_debug_monitor(attach_pid=attach_pid)
@@ -424,7 +425,8 @@ def connect_to_debug_monitor(self, attach_pid=None):
 
 # And wait a random length of time before next attempt, to avoid
 # collisions.
-time.sleep(random.randint(1, 5))
+time.sleep(attempt_wait)
+attempt_wait *= 1.2
 
 # Now grab a new port number.
 self.port = self.get_next_port()



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


[Lldb-commits] [lldb] [lldb][NFC] Remove unused field Platform::m_remote_url (PR #118411)

2024-12-02 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Alex Langford (bulbazord)


Changes



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


1 Files Affected:

- (modified) lldb/include/lldb/Target/Platform.h (-3) 


``diff
diff --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index 920f80bc733174..f8a2cbf0d5d049 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -473,8 +473,6 @@ class Platform : public PluginInterface {
   LLVM_PRETTY_FUNCTION, GetName()));
   }
 
-  const std::string &GetRemoteURL() const { return m_remote_url; }
-
   bool IsHost() const {
 return m_is_host; // Is this the default host platform?
   }
@@ -977,7 +975,6 @@ class Platform : public PluginInterface {
   std::string m_sdk_build;
   FileSpec m_working_dir; // The working directory which is used when 
installing
   // modules that have no install path set
-  std::string m_remote_url;
   std::string m_hostname;
   llvm::VersionTuple m_os_version;
   ArchSpec

``




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


[Lldb-commits] [lldb] [lldb][NFC] Remove unused field Platform::m_remote_url (PR #118411)

2024-12-02 Thread Alex Langford via lldb-commits

https://github.com/bulbazord created 
https://github.com/llvm/llvm-project/pull/118411

None

>From 41ce9de83da1a7131bf6c479fd0de3a57f5b8113 Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Mon, 2 Dec 2024 14:42:25 -0800
Subject: [PATCH] [lldb][NFC] Remove unused field Platform::m_remote_url

---
 lldb/include/lldb/Target/Platform.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/lldb/include/lldb/Target/Platform.h 
b/lldb/include/lldb/Target/Platform.h
index 920f80bc733174..f8a2cbf0d5d049 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -473,8 +473,6 @@ class Platform : public PluginInterface {
   LLVM_PRETTY_FUNCTION, GetName()));
   }
 
-  const std::string &GetRemoteURL() const { return m_remote_url; }
-
   bool IsHost() const {
 return m_is_host; // Is this the default host platform?
   }
@@ -977,7 +975,6 @@ class Platform : public PluginInterface {
   std::string m_sdk_build;
   FileSpec m_working_dir; // The working directory which is used when 
installing
   // modules that have no install path set
-  std::string m_remote_url;
   std::string m_hostname;
   llvm::VersionTuple m_os_version;
   ArchSpec

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


[Lldb-commits] [lldb] [lldb][NFC] Remove unused field Platform::m_remote_url (PR #118411)

2024-12-02 Thread Med Ismail Bennani via lldb-commits

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

This doesn't seem to be used anywhere. LGTM!

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


[Lldb-commits] [lldb] [lldb][NFC] Remove unused field Platform::m_remote_url (PR #118411)

2024-12-02 Thread Jonas Devlieghere via lldb-commits

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

🚢

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


[Lldb-commits] [lldb] [lldb][NFC] Remove unused field Platform::m_remote_url (PR #118411)

2024-12-02 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] Add 'FindFirstSymbolWithNameAndType()' to ModuleList. (PR #117777)

2024-12-02 Thread Pavel Labath via lldb-commits

labath wrote:

> > I'm only using it in an internal branch
> 
> Not sure what the protocol is for this (CC @JDevlieghere @labath). At the 
> very least we should have some coverage for it in the test-suite. There's 
> precedent for this, e.g., APIs that only get exercised on the Swift branch, 
> but at least those are on a public fork and tested on public build-bots.

I don't really know how to answer this generally, but I'm not particularly 
concerned about this change, since its just a wrapper over another API and it 
fits in with the general design of our other APIs. A test would definitely be 
nice, but I don't know how easy it is to set up (given its an internal API, it 
would need to go through a unit test, etc.).

I think the easiest way to motivate this change and satisfy the testing 
requirement would be to find upstream use case(s) for this function -- and it 
looks like this is a perfect candidate for the simplification of 
MemoryHistoryAsan::CreateInstance.


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


[Lldb-commits] [lldb] [lldb] rename fooSynthProvider module (PR #118094)

2024-12-02 Thread Pavel Labath via lldb-commits

labath wrote:

> Maybe it's true, I've tried to test lldb on riscv using dotest.py with remote 
> debugging options.

It sounds like you're using the mode which runs all tests (files) in the same 
process. I don't know if anyone uses it these days (and this error sort of says 
"no"). I don't think this change is bad, but I fear you may run into more of 
these inter-test interactions if you keep using it (some of them may not be so 
easy to fix). If I were you, I'd switch to the (standard) one-process-per-test 
mode.

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


[Lldb-commits] [lldb] [lldb] Simplify DumpValueObjectOptions::PointerDepth (NFC) (PR #117504)

2024-12-02 Thread Dave Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Update dwim-print to show expanded objc instances (PR #117500)

2024-12-02 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/117500

>From 3199d3ee3817a8551cda1f5fce6083fef1c079d9 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Sat, 23 Nov 2024 18:25:22 -0800
Subject: [PATCH 1/3] [lldb] Update dwim-print to show expanded objc instances

When printing an ObjC object, which is a pointer, lldb has handled it like it 
treats any
other pointer, printing only pointer address and class name. The object is not 
expanded,
and its children are not shown.

This change updates the dwim-print to print expanded objc pointers - it is 
assumed
that's what the user meant.

Note that this is currently possible using the `--ptr-depth`/`-P` flag, but the 
default
is 0. With this change, when dwim-print prints objc objects, the default is 
effectively
changed to 1.
---
 .../lldb/DataFormatters/DumpValueObjectOptions.h |  3 +++
 lldb/source/Commands/CommandObjectDWIMPrint.cpp  |  3 ++-
 .../DataFormatters/DumpValueObjectOptions.cpp|  6 ++
 .../source/DataFormatters/ValueObjectPrinter.cpp | 14 --
 lldb/test/API/commands/dwim-print/objc/Makefile  |  3 +++
 .../dwim-print/objc/TestDWIMPrintObjC.py | 16 
 lldb/test/API/commands/dwim-print/objc/main.m| 15 +++
 7 files changed, 53 insertions(+), 7 deletions(-)
 create mode 100644 lldb/test/API/commands/dwim-print/objc/Makefile
 create mode 100644 lldb/test/API/commands/dwim-print/objc/TestDWIMPrintObjC.py
 create mode 100644 lldb/test/API/commands/dwim-print/objc/main.m

diff --git a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h 
b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
index c7f8116c48..7e213f29b3bc0a 100644
--- a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
+++ b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
@@ -125,6 +125,8 @@ class DumpValueObjectOptions {
 
   DumpValueObjectOptions &SetRevealEmptyAggregates(bool reveal = true);
 
+  DumpValueObjectOptions &SetExpandPointerTypeFlags(unsigned flags);
+
   DumpValueObjectOptions &SetElementCount(uint32_t element_count = 0);
 
   DumpValueObjectOptions &
@@ -142,6 +144,7 @@ class DumpValueObjectOptions {
   DeclPrintingHelper m_decl_printing_helper;
   ChildPrintingDecider m_child_printing_decider;
   PointerAsArraySettings m_pointer_as_array;
+  unsigned m_expand_ptr_type_flags = 0;
   bool m_use_synthetic : 1;
   bool m_scope_already_checked : 1;
   bool m_flat_output : 1;
diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp 
b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 62c4e74d853ad1..8bfef15036cc7e 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -87,7 +87,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 
   DumpValueObjectOptions dump_options = m_varobj_options.GetAsDumpOptions(
   m_expr_options.m_verbosity, m_format_options.GetFormat());
-  dump_options.SetHideRootName(suppress_result);
+  dump_options.SetHideRootName(suppress_result)
+  .SetExpandPointerTypeFlags(lldb::eTypeIsObjC);
 
   bool is_po = m_varobj_options.use_objc;
 
diff --git a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp 
b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
index 18d590d47d9a0c..a4db0d3cb240f1 100644
--- a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
+++ b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
@@ -201,6 +201,12 @@ DumpValueObjectOptions::SetRevealEmptyAggregates(bool 
reveal) {
   return *this;
 }
 
+DumpValueObjectOptions &
+DumpValueObjectOptions::SetExpandPointerTypeFlags(unsigned flags) {
+  m_expand_ptr_type_flags = flags;
+  return *this;
+}
+
 DumpValueObjectOptions &
 DumpValueObjectOptions::SetElementCount(uint32_t element_count) {
   m_pointer_as_array = PointerAsArraySettings(element_count);
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp 
b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index face38253efab8..83db9292c5e76e 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -554,12 +554,14 @@ bool ValueObjectPrinter::ShouldPrintChildren(
   return false;
 
 const bool is_root_level = m_curr_depth == 0;
-
-if (is_ref && is_root_level && print_children) {
-  // If this is the root object (depth is zero) that we are showing and
-  // it is a reference, and no pointer depth has been supplied print out
-  // what it references. Don't do this at deeper depths otherwise we can
-  // end up with infinite recursion...
+const bool is_expanded_ptr =
+is_ptr && m_type_flags.Test(m_options.m_expand_ptr_type_flags);
+
+if ((is_ref || is_expanded_ptr) && is_root_level && print_children) {
+  // If this is the root object (depth is zero) that we are showing and it
+  // is either a reference or a preferred type of pointer, then print it.
+  // Don't do this at deeper depths otherwise 

[Lldb-commits] [lldb] [lldb][Process/Linux] Introduce LoongArch64 hw break/watchpoint support (PR #118043)

2024-12-02 Thread Lu Weining via lldb-commits


@@ -337,4 +354,471 @@ 
NativeRegisterContextLinux_loongarch64::GetExpeditedRegisters(
   return expedited_reg_nums;
 }
 
+uint32_t
+NativeRegisterContextLinux_loongarch64::NumSupportedHardwareBreakpoints() {
+  Log *log = GetLog(LLDBLog::Breakpoints);
+
+  // Read hardware breakpoint and watchpoint information.
+  Status error = ReadHardwareDebugInfo();
+
+  if (error.Fail()) {
+LLDB_LOG(log, "failed to read debug registers");
+return 0;
+  }
+
+  LLDB_LOG(log, "{0}", m_max_hbp_supported);

SixWeining wrote:

Could we make the log message more readable? For example `Supported hardware 
breakpoints: {0}`

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


[Lldb-commits] [lldb] 0a96161 - [lldb] Simplify DumpValueObjectOptions::PointerDepth (NFC) (#117504)

2024-12-02 Thread via lldb-commits

Author: Dave Lee
Date: 2024-12-02T16:23:26-08:00
New Revision: 0a96161beb161933e64e188bfb0754df494c3a58

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

LOG: [lldb] Simplify DumpValueObjectOptions::PointerDepth (NFC) (#117504)

`Mode::Always` and `Mode::Default` are handled identically.
`Mode::Never` is the same as having a count of 0.

Added: 


Modified: 
lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
lldb/source/DataFormatters/DumpValueObjectOptions.cpp
lldb/source/DataFormatters/ValueObjectPrinter.cpp
lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp

Removed: 




diff  --git a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h 
b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
index c7f8116c48..ce15963ab5662c 100644
--- a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
+++ b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
@@ -22,13 +22,12 @@ namespace lldb_private {
 class DumpValueObjectOptions {
 public:
   struct PointerDepth {
-enum class Mode { Always, Default, Never } m_mode;
-uint32_t m_count;
+uint32_t m_count = 0;
 
 PointerDepth Decremented() const {
   if (m_count > 0)
-return PointerDepth{m_mode, m_count - 1};
-  return PointerDepth{m_mode, m_count};
+return {m_count - 1};
+  return *this;
 }
 
 bool CanAllowExpansion() const;
@@ -65,8 +64,7 @@ class DumpValueObjectOptions {
 
   DumpValueObjectOptions(ValueObject &valobj);
 
-  DumpValueObjectOptions &
-  SetMaximumPointerDepth(PointerDepth depth = {PointerDepth::Mode::Never, 0});
+  DumpValueObjectOptions &SetMaximumPointerDepth(uint32_t depth);
 
   DumpValueObjectOptions &SetMaximumDepth(uint32_t depth, bool is_default);
 

diff  --git a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp 
b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
index 18d590d47d9a0c..b952fb643f13ef 100644
--- a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
+++ b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
@@ -14,10 +14,8 @@ using namespace lldb;
 using namespace lldb_private;
 
 DumpValueObjectOptions::DumpValueObjectOptions()
-: m_summary_sp(), m_root_valobj_name(),
-  m_max_ptr_depth(PointerDepth{PointerDepth::Mode::Default, 0}),
-  m_decl_printing_helper(), m_child_printing_decider(),
-  m_pointer_as_array(), m_use_synthetic(true),
+: m_summary_sp(), m_root_valobj_name(), m_decl_printing_helper(),
+  m_child_printing_decider(), m_pointer_as_array(), m_use_synthetic(true),
   m_scope_already_checked(false), m_flat_output(false), 
m_ignore_cap(false),
   m_show_types(false), m_show_location(false), m_use_objc(false),
   m_hide_root_type(false), m_hide_root_name(false), m_hide_name(false),
@@ -33,8 +31,8 @@ DumpValueObjectOptions::DumpValueObjectOptions(ValueObject 
&valobj)
 }
 
 DumpValueObjectOptions &
-DumpValueObjectOptions::SetMaximumPointerDepth(PointerDepth depth) {
-  m_max_ptr_depth = depth;
+DumpValueObjectOptions::SetMaximumPointerDepth(uint32_t depth) {
+  m_max_ptr_depth = {depth};
   return *this;
 }
 

diff  --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp 
b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index face38253efab8..01e604e019f25f 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -503,14 +503,7 @@ ValueObjectPrinter::PrintObjectDescriptionIfNeeded(bool 
value_printed,
 }
 
 bool DumpValueObjectOptions::PointerDepth::CanAllowExpansion() const {
-  switch (m_mode) {
-  case Mode::Always:
-  case Mode::Default:
-return m_count > 0;
-  case Mode::Never:
-return false;
-  }
-  return false;
+  return m_count > 0;
 }
 
 bool ValueObjectPrinter::ShouldPrintChildren(

diff  --git a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp 
b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
index 0e8c1f4b5f1d9a..d633c469e603ec 100644
--- a/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
+++ b/lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp
@@ -190,8 +190,7 @@ DumpValueObjectOptions 
OptionGroupValueObjectDisplay::GetAsDumpOptions(
 LanguageRuntimeDescriptionDisplayVerbosity lang_descr_verbosity,
 lldb::Format format, lldb::TypeSummaryImplSP summary_sp) {
   DumpValueObjectOptions options;
-  options.SetMaximumPointerDepth(
-  {DumpValueObjectOptions::PointerDepth::Mode::Always, ptr_depth});
+  options.SetMaximumPointerDepth(ptr_depth);
   if (use_objc)
 options.SetShowSummary(false);
   else



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


[Lldb-commits] [lldb] [lldb] Update dwim-print to show expanded objc instances (PR #117500)

2024-12-02 Thread Dave Lee via lldb-commits

https://github.com/kastiglione updated 
https://github.com/llvm/llvm-project/pull/117500

>From 3199d3ee3817a8551cda1f5fce6083fef1c079d9 Mon Sep 17 00:00:00 2001
From: Dave Lee 
Date: Sat, 23 Nov 2024 18:25:22 -0800
Subject: [PATCH 1/2] [lldb] Update dwim-print to show expanded objc instances

When printing an ObjC object, which is a pointer, lldb has handled it like it 
treats any
other pointer, printing only pointer address and class name. The object is not 
expanded,
and its children are not shown.

This change updates the dwim-print to print expanded objc pointers - it is 
assumed
that's what the user meant.

Note that this is currently possible using the `--ptr-depth`/`-P` flag, but the 
default
is 0. With this change, when dwim-print prints objc objects, the default is 
effectively
changed to 1.
---
 .../lldb/DataFormatters/DumpValueObjectOptions.h |  3 +++
 lldb/source/Commands/CommandObjectDWIMPrint.cpp  |  3 ++-
 .../DataFormatters/DumpValueObjectOptions.cpp|  6 ++
 .../source/DataFormatters/ValueObjectPrinter.cpp | 14 --
 lldb/test/API/commands/dwim-print/objc/Makefile  |  3 +++
 .../dwim-print/objc/TestDWIMPrintObjC.py | 16 
 lldb/test/API/commands/dwim-print/objc/main.m| 15 +++
 7 files changed, 53 insertions(+), 7 deletions(-)
 create mode 100644 lldb/test/API/commands/dwim-print/objc/Makefile
 create mode 100644 lldb/test/API/commands/dwim-print/objc/TestDWIMPrintObjC.py
 create mode 100644 lldb/test/API/commands/dwim-print/objc/main.m

diff --git a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h 
b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
index c7f8116c48..7e213f29b3bc0a 100644
--- a/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
+++ b/lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
@@ -125,6 +125,8 @@ class DumpValueObjectOptions {
 
   DumpValueObjectOptions &SetRevealEmptyAggregates(bool reveal = true);
 
+  DumpValueObjectOptions &SetExpandPointerTypeFlags(unsigned flags);
+
   DumpValueObjectOptions &SetElementCount(uint32_t element_count = 0);
 
   DumpValueObjectOptions &
@@ -142,6 +144,7 @@ class DumpValueObjectOptions {
   DeclPrintingHelper m_decl_printing_helper;
   ChildPrintingDecider m_child_printing_decider;
   PointerAsArraySettings m_pointer_as_array;
+  unsigned m_expand_ptr_type_flags = 0;
   bool m_use_synthetic : 1;
   bool m_scope_already_checked : 1;
   bool m_flat_output : 1;
diff --git a/lldb/source/Commands/CommandObjectDWIMPrint.cpp 
b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
index 62c4e74d853ad1..8bfef15036cc7e 100644
--- a/lldb/source/Commands/CommandObjectDWIMPrint.cpp
+++ b/lldb/source/Commands/CommandObjectDWIMPrint.cpp
@@ -87,7 +87,8 @@ void CommandObjectDWIMPrint::DoExecute(StringRef command,
 
   DumpValueObjectOptions dump_options = m_varobj_options.GetAsDumpOptions(
   m_expr_options.m_verbosity, m_format_options.GetFormat());
-  dump_options.SetHideRootName(suppress_result);
+  dump_options.SetHideRootName(suppress_result)
+  .SetExpandPointerTypeFlags(lldb::eTypeIsObjC);
 
   bool is_po = m_varobj_options.use_objc;
 
diff --git a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp 
b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
index 18d590d47d9a0c..a4db0d3cb240f1 100644
--- a/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
+++ b/lldb/source/DataFormatters/DumpValueObjectOptions.cpp
@@ -201,6 +201,12 @@ DumpValueObjectOptions::SetRevealEmptyAggregates(bool 
reveal) {
   return *this;
 }
 
+DumpValueObjectOptions &
+DumpValueObjectOptions::SetExpandPointerTypeFlags(unsigned flags) {
+  m_expand_ptr_type_flags = flags;
+  return *this;
+}
+
 DumpValueObjectOptions &
 DumpValueObjectOptions::SetElementCount(uint32_t element_count) {
   m_pointer_as_array = PointerAsArraySettings(element_count);
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp 
b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index face38253efab8..83db9292c5e76e 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -554,12 +554,14 @@ bool ValueObjectPrinter::ShouldPrintChildren(
   return false;
 
 const bool is_root_level = m_curr_depth == 0;
-
-if (is_ref && is_root_level && print_children) {
-  // If this is the root object (depth is zero) that we are showing and
-  // it is a reference, and no pointer depth has been supplied print out
-  // what it references. Don't do this at deeper depths otherwise we can
-  // end up with infinite recursion...
+const bool is_expanded_ptr =
+is_ptr && m_type_flags.Test(m_options.m_expand_ptr_type_flags);
+
+if ((is_ref || is_expanded_ptr) && is_root_level && print_children) {
+  // If this is the root object (depth is zero) that we are showing and it
+  // is either a reference or a preferred type of pointer, then print it.
+  // Don't do this at deeper depths otherwise 

[Lldb-commits] [lldb] [lldb][Process/Linux] Introduce LoongArch64 hw break/watchpoint support (PR #118043)

2024-12-02 Thread David Spickett via lldb-commits

DavidSpickett wrote:

And I don't see that LoongArch is doing anything unusual, so I think this is 
just a refactoring exercise. It is native code so if you don't have an AArch64 
machine to build on, I can test the PR for you.

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


[Lldb-commits] [lldb] [lldb][Process/Linux] Introduce LoongArch64 hw break/watchpoint support (PR #118043)

2024-12-02 Thread Lu Weining via lldb-commits


@@ -337,4 +354,471 @@ 
NativeRegisterContextLinux_loongarch64::GetExpeditedRegisters(
   return expedited_reg_nums;
 }
 
+uint32_t
+NativeRegisterContextLinux_loongarch64::NumSupportedHardwareBreakpoints() {
+  Log *log = GetLog(LLDBLog::Breakpoints);
+
+  // Read hardware breakpoint and watchpoint information.
+  Status error = ReadHardwareDebugInfo();
+
+  if (error.Fail()) {
+LLDB_LOG(log, "failed to read debug registers");
+return 0;
+  }
+
+  LLDB_LOG(log, "{0}", m_max_hbp_supported);
+  return m_max_hbp_supported;
+}
+
+uint32_t
+NativeRegisterContextLinux_loongarch64::SetHardwareBreakpoint(lldb::addr_t 
addr,
+  size_t size) {
+  Log *log = GetLog(LLDBLog::Breakpoints);
+  LLDB_LOG(log, "addr: {0:x}, size: {1:x}", addr, size);

SixWeining wrote:

Ditto.

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


[Lldb-commits] [lldb] [lldb][Process/Linux] Introduce LoongArch64 hw break/watchpoint support (PR #118043)

2024-12-02 Thread Lu Weining via lldb-commits


@@ -337,4 +354,471 @@ 
NativeRegisterContextLinux_loongarch64::GetExpeditedRegisters(
   return expedited_reg_nums;
 }
 
+uint32_t
+NativeRegisterContextLinux_loongarch64::NumSupportedHardwareBreakpoints() {
+  Log *log = GetLog(LLDBLog::Breakpoints);
+
+  // Read hardware breakpoint and watchpoint information.
+  Status error = ReadHardwareDebugInfo();
+
+  if (error.Fail()) {
+LLDB_LOG(log, "failed to read debug registers");
+return 0;
+  }
+
+  LLDB_LOG(log, "{0}", m_max_hbp_supported);
+  return m_max_hbp_supported;
+}
+
+uint32_t
+NativeRegisterContextLinux_loongarch64::SetHardwareBreakpoint(lldb::addr_t 
addr,
+  size_t size) {
+  Log *log = GetLog(LLDBLog::Breakpoints);
+  LLDB_LOG(log, "addr: {0:x}, size: {1:x}", addr, size);
+
+  // Read hardware breakpoint and watchpoint information.
+  Status error = ReadHardwareDebugInfo();
+  if (error.Fail()) {
+LLDB_LOG(log, "unable to set breakpoint: failed to read debug registers");
+return LLDB_INVALID_INDEX32;
+  }
+
+  uint32_t bp_index = 0;
+
+  // Check if size has a valid hardware breakpoint length.
+  if (size != 4)
+return LLDB_INVALID_INDEX32; // Invalid size for a LoongArch hardware
+ // breakpoint
+
+  // Check 4-byte alignment for hardware breakpoint target address.
+  if (addr & 0x03)
+return LLDB_INVALID_INDEX32; // Invalid address, should be 4-byte aligned.
+
+  // Iterate over stored breakpoints and find a free bp_index
+  bp_index = LLDB_INVALID_INDEX32;
+  for (uint32_t i = 0; i < m_max_hbp_supported; i++) {
+if (!BreakpointIsEnabled(i))
+  bp_index = i; // Mark last free slot
+else if (m_hbp_regs[i].address == addr)
+  return LLDB_INVALID_INDEX32; // We do not support duplicate breakpoints.
+  }
+
+  if (bp_index == LLDB_INVALID_INDEX32)
+return LLDB_INVALID_INDEX32;
+
+  // Update breakpoint in local cache
+  m_hbp_regs[bp_index].address = addr;
+  m_hbp_regs[bp_index].control = g_enable_bit;
+
+  // PTRACE call to set corresponding hardware breakpoint register.
+  error = WriteHardwareDebugRegs(eDREGTypeBREAK);
+
+  if (error.Fail()) {
+m_hbp_regs[bp_index].address = 0;
+m_hbp_regs[bp_index].control = 0;
+
+LLDB_LOG(log, "unable to set breakpoint: failed to write debug registers");
+return LLDB_INVALID_INDEX32;
+  }
+
+  return bp_index;
+}
+bool NativeRegisterContextLinux_loongarch64::ClearHardwareBreakpoint(
+uint32_t hw_idx) {
+  Log *log = GetLog(LLDBLog::Breakpoints);
+  LLDB_LOG(log, "hw_idx: {0}", hw_idx);
+
+  // Read hardware breakpoint and watchpoint information.
+  Status error = ReadHardwareDebugInfo();
+  if (error.Fail()) {
+LLDB_LOG(log, "unable to clear breakpoint: failed to read debug 
registers");
+return false;
+  }
+
+  if (hw_idx >= m_max_hbp_supported)
+return false;
+
+  // Create a backup we can revert to in case of failure.
+  lldb::addr_t tempAddr = m_hbp_regs[hw_idx].address;
+  uint32_t tempControl = m_hbp_regs[hw_idx].control;
+
+  m_hbp_regs[hw_idx].control = 0;
+  m_hbp_regs[hw_idx].address = 0;
+
+  // PTRACE call to clear corresponding hardware breakpoint register.
+  error = WriteHardwareDebugRegs(eDREGTypeBREAK);
+
+  if (error.Fail()) {
+m_hbp_regs[hw_idx].control = tempControl;
+m_hbp_regs[hw_idx].address = tempAddr;
+
+LLDB_LOG(log,
+ "unable to clear breakpoint: failed to write debug registers");
+return false;
+  }
+
+  return true;
+}
+Status NativeRegisterContextLinux_loongarch64::GetHardwareBreakHitIndex(
+uint32_t &bp_index, lldb::addr_t trap_addr) {
+  Log *log = GetLog(LLDBLog::Breakpoints);
+
+  LLDB_LOGF(log, "NativeRegisterContextLinux_loongarch64::%s()", __FUNCTION__);
+
+  lldb::addr_t break_addr;
+
+  for (bp_index = 0; bp_index < m_max_hbp_supported; ++bp_index) {
+break_addr = m_hbp_regs[bp_index].address;
+
+if (BreakpointIsEnabled(bp_index) && trap_addr == break_addr) {
+  m_hbp_regs[bp_index].hit_addr = trap_addr;
+  return Status();
+}
+  }
+
+  bp_index = LLDB_INVALID_INDEX32;
+  return Status();
+}
+Status NativeRegisterContextLinux_loongarch64::ClearAllHardwareBreakpoints() {
+  Log *log = GetLog(LLDBLog::Breakpoints);
+
+  LLDB_LOGF(log, "NativeRegisterContextLinux_loongarch64::%s()", __FUNCTION__);
+
+  // Read hardware breakpoint and watchpoint information.
+  Status error = ReadHardwareDebugInfo();
+  if (error.Fail())
+return error;
+
+  for (uint32_t i = 0; i < m_max_hbp_supported; i++) {
+if (!BreakpointIsEnabled(i))
+  continue;
+// Create a backup we can revert to in case of failure.
+lldb::addr_t tempAddr = m_hbp_regs[i].address;
+uint32_t tempControl = m_hbp_regs[i].control;
+
+// Clear watchpoints in local cache
+m_hbp_regs[i].control = 0;
+m_hbp_regs[i].address = 0;
+
+// Ptrace call to update hardware debug registers
+error = WriteHardwareDebugRegs(eDREGTypeBREAK);
+
+if (error.Fai

[Lldb-commits] [lldb] [lldb] Use the function block as a source for function ranges (PR #117996)

2024-12-02 Thread Jason Molenda via lldb-commits

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

This looks reasonable to me.

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