[Lldb-commits] [lldb] [lldb] Speed up FindInMemory tests (PR #111951)

2024-10-10 Thread Igor Kudrin via lldb-commits

https://github.com/igorkudrin created 
https://github.com/llvm/llvm-project/pull/111951

A memory region can be relatively large. Searching for a value in the entire 
region is time-consuming, especially when running tests against a remote 
target, because the memory data is transferred in small chunks over a 
relatively slow GDB remote protocol. The patch limits the address range to be 
searched to 2K, which seems sufficient for these tests. In my setup, for local 
runs, these tests now take half the time they did before the patch. For a 
remote target, the improvement is even more significant.

>From 6ea11737a9edbf1a1be413c2eaa7075438effb05 Mon Sep 17 00:00:00 2001
From: Igor Kudrin 
Date: Thu, 10 Oct 2024 20:27:10 -0700
Subject: [PATCH] [lldb] Speed up FindInMemory tests

A memory region can be relatively large. Searching for a value in the
entire region is time-consuming, especially when running tests against
a remote target, because the memory data is transferred in small chunks
over a relatively slow GDBRemote protocol. The patch limits the address
range to be searched to 2K, which seems sufficient for these tests. In
my setup, for local runs, these tests now take half the time they did
before the patch. For a remote target, the improvement is even more
significant.
---
 .../find_in_memory/TestFindInMemory.py| 10 ++--
 .../find_in_memory/TestFindRangesInMemory.py  | 16 +++---
 .../find_in_memory/address_ranges_helper.py   | 50 ---
 3 files changed, 45 insertions(+), 31 deletions(-)

diff --git a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py 
b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py
index 9ab4619b1f8f4f..04e807c5c6201d 100644
--- a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py
+++ b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py
@@ -55,7 +55,7 @@ def test_find_in_memory_ok(self):
 error = lldb.SBError()
 addr = self.process.FindInMemory(
 SINGLE_INSTANCE_PATTERN_STACK,
-GetStackRange(self),
+GetStackRange(self, True),
 1,
 error,
 )
@@ -70,7 +70,7 @@ def test_find_in_memory_double_instance_ok(self):
 error = lldb.SBError()
 addr = self.process.FindInMemory(
 DOUBLE_INSTANCE_PATTERN_HEAP,
-GetHeapRanges(self)[0],
+GetHeapRanges(self, True)[0],
 1,
 error,
 )
@@ -86,7 +86,7 @@ def test_find_in_memory_invalid_alignment(self):
 error = lldb.SBError()
 addr = self.process.FindInMemory(
 SINGLE_INSTANCE_PATTERN_STACK,
-GetStackRange(self),
+GetStackRange(self, True),
 0,
 error,
 )
@@ -118,7 +118,7 @@ def test_find_in_memory_invalid_buffer(self):
 error = lldb.SBError()
 addr = self.process.FindInMemory(
 "",
-GetStackRange(self),
+GetStackRange(self, True),
 1,
 error,
 )
@@ -131,7 +131,7 @@ def test_find_in_memory_unaligned(self):
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertState(self.process.GetState(), lldb.eStateStopped, 
PROCESS_STOPPED)
 error = lldb.SBError()
-range = GetAlignedRange(self)
+range = GetAlignedRange(self, True)
 
 # First we make sure the pattern is found with alignment 1
 addr = self.process.FindInMemory(
diff --git a/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py 
b/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py
index 31bc0e99f4914f..895c527430f218 100644
--- a/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py
+++ b/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py
@@ -30,7 +30,7 @@ def test_find_ranges_in_memory_two_matches(self):
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertState(self.process.GetState(), lldb.eStateStopped, 
PROCESS_STOPPED)
 
-addr_ranges = GetHeapRanges(self)
+addr_ranges = GetHeapRanges(self, True)
 error = lldb.SBError()
 matches = self.process.FindRangesInMemory(
 DOUBLE_INSTANCE_PATTERN_HEAP,
@@ -48,7 +48,7 @@ def test_find_ranges_in_memory_one_match(self):
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertState(self.process.GetState(), lldb.eStateStopped, 
PROCESS_STOPPED)
 
-addr_ranges = GetStackRanges(self)
+addr_ranges = GetStackRanges(self, True)
 error = lldb.SBError()
 matches = self.process.FindRangesInMemory(
 SINGLE_INSTANCE_PATTERN_STACK,
@@ -66,7 +66,7 @@ def 
test_find_ranges_in_memory_one_match_multiple_ranges(self):
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertState(self.process.GetState(), lldb.eStateStopped, 
PROCESS_STOPPED)
 
-addr_ranges = GetRanges(self)
+addr_ranges = GetRanges(self, True)

[Lldb-commits] [lldb] [lldb] Speed up FindInMemory tests (PR #111951)

2024-10-10 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Igor Kudrin (igorkudrin)


Changes

A memory region can be relatively large. Searching for a value in the entire 
region is time-consuming, especially when running tests against a remote 
target, because the memory data is transferred in small chunks over a 
relatively slow GDB remote protocol. The patch limits the address range to be 
searched to 2K, which seems sufficient for these tests. In my setup, for local 
runs, these tests now take half the time they did before the patch. For a 
remote target, the improvement is even more significant.

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


3 Files Affected:

- (modified) lldb/test/API/python_api/find_in_memory/TestFindInMemory.py (+5-5) 
- (modified) lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py 
(+8-8) 
- (modified) lldb/test/API/python_api/find_in_memory/address_ranges_helper.py 
(+32-18) 


``diff
diff --git a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py 
b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py
index 9ab4619b1f8f4f..04e807c5c6201d 100644
--- a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py
+++ b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py
@@ -55,7 +55,7 @@ def test_find_in_memory_ok(self):
 error = lldb.SBError()
 addr = self.process.FindInMemory(
 SINGLE_INSTANCE_PATTERN_STACK,
-GetStackRange(self),
+GetStackRange(self, True),
 1,
 error,
 )
@@ -70,7 +70,7 @@ def test_find_in_memory_double_instance_ok(self):
 error = lldb.SBError()
 addr = self.process.FindInMemory(
 DOUBLE_INSTANCE_PATTERN_HEAP,
-GetHeapRanges(self)[0],
+GetHeapRanges(self, True)[0],
 1,
 error,
 )
@@ -86,7 +86,7 @@ def test_find_in_memory_invalid_alignment(self):
 error = lldb.SBError()
 addr = self.process.FindInMemory(
 SINGLE_INSTANCE_PATTERN_STACK,
-GetStackRange(self),
+GetStackRange(self, True),
 0,
 error,
 )
@@ -118,7 +118,7 @@ def test_find_in_memory_invalid_buffer(self):
 error = lldb.SBError()
 addr = self.process.FindInMemory(
 "",
-GetStackRange(self),
+GetStackRange(self, True),
 1,
 error,
 )
@@ -131,7 +131,7 @@ def test_find_in_memory_unaligned(self):
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertState(self.process.GetState(), lldb.eStateStopped, 
PROCESS_STOPPED)
 error = lldb.SBError()
-range = GetAlignedRange(self)
+range = GetAlignedRange(self, True)
 
 # First we make sure the pattern is found with alignment 1
 addr = self.process.FindInMemory(
diff --git a/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py 
b/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py
index 31bc0e99f4914f..895c527430f218 100644
--- a/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py
+++ b/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py
@@ -30,7 +30,7 @@ def test_find_ranges_in_memory_two_matches(self):
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertState(self.process.GetState(), lldb.eStateStopped, 
PROCESS_STOPPED)
 
-addr_ranges = GetHeapRanges(self)
+addr_ranges = GetHeapRanges(self, True)
 error = lldb.SBError()
 matches = self.process.FindRangesInMemory(
 DOUBLE_INSTANCE_PATTERN_HEAP,
@@ -48,7 +48,7 @@ def test_find_ranges_in_memory_one_match(self):
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertState(self.process.GetState(), lldb.eStateStopped, 
PROCESS_STOPPED)
 
-addr_ranges = GetStackRanges(self)
+addr_ranges = GetStackRanges(self, True)
 error = lldb.SBError()
 matches = self.process.FindRangesInMemory(
 SINGLE_INSTANCE_PATTERN_STACK,
@@ -66,7 +66,7 @@ def 
test_find_ranges_in_memory_one_match_multiple_ranges(self):
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertState(self.process.GetState(), lldb.eStateStopped, 
PROCESS_STOPPED)
 
-addr_ranges = GetRanges(self)
+addr_ranges = GetRanges(self, True)
 addr_ranges.Append(lldb.SBAddressRange())
 self.assertGreater(addr_ranges.GetSize(), 2)
 error = lldb.SBError()
@@ -86,7 +86,7 @@ def test_find_ranges_in_memory_one_match_max(self):
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertState(self.process.GetState(), lldb.eStateStopped, 
PROCESS_STOPPED)
 
-addr_ranges = GetHeapRanges(self)
+addr_ranges = GetHeapRanges(self, True)
 error = lldb.SBError()
 matches = self.process.FindRangesInMemory(
 DOUBLE_INSTANCE_PATTERN

[Lldb-commits] [lldb] [lldb][NFC] Fix a build failure with MSVC (PR #111231)

2024-10-10 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

> > Looks good, I guess. Is that constructor even necessary, given that it just 
> > forwards the argument to the base class, and we already have the forwarding 
> > `using` declaration?
> 
> The constructor looks redundant at the moment, perhaps it is just a legacy 
> from the early stages of patch #106442. Maybe some other constructors can 
> also be reduced, for example, `Win32Error::Win32Error()`. However, I may not 
> fully understand the intentions of the author of the original patch, so I'd 
> prefer @adrian-prantl to do the cleanup if necessary. My patch is only 
> intended to fix the immediate problem.

This constructor is more a leftover after a bunch of refactoring, your change 
LGTM!

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


[Lldb-commits] [lldb] [lldb] Add include for SBLanguages in lldb-enumerations (PR #111907)

2024-10-10 Thread Vladimir Vereschaka via lldb-commits

vvereschaka wrote:

@chelcassanova `lldb/API/SBLanguages.h` is generated file. I suppose its 
generation must be enabled for the `lldb-server` target in that case; otherwise 
we get the following build errors:
```
In file included from 
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/lldb-types.h:12:
/home/buildbot/worker/as-builder-9/lldb-remote-linux-ubuntu/llvm-project/lldb/include/lldb/lldb-enumerations.h:15:10:
 fatal error: 'lldb/API/SBLanguages.h' file not found
   15 | #include 
  |  ^~~~
1 error generated.
```
https://lab.llvm.org/staging/#/builders/195/builds/4266

i.e. when only 'lldb-server' target gets built (`cmake --build . --target 
lldb-server`)

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


[Lldb-commits] [lldb] c99b365 - Revert "[lldb] Add include for SBLanguages in lldb-enumerations (#111907)"

2024-10-10 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2024-10-10T14:50:34-07:00
New Revision: c99b36554745837c549e1b46cd60db70588affcf

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

LOG: Revert "[lldb] Add include for SBLanguages in lldb-enumerations (#111907)"

Temporarily Revert until Chelsea can look at this.  With a clean build,
SBLanguages.h won't be generated in the build directory at the point
when it is included by lldb-enumerations when compiling e.g.
Broadcaster.cpp.  On a clean build (no pre-existing build directory),
the dependency ordering is not explicitly stated so the build will fail.
An incremental build will succeed.

This reverts commit b3554265f24aa570bbc8693af8420a306c459f94.

Added: 


Modified: 
lldb/include/lldb/lldb-enumerations.h

Removed: 




diff  --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 217cd7f65cc1c4..232d1dfdb5c9d0 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -12,8 +12,6 @@
 #include 
 #include 
 
-#include 
-
 #ifndef SWIG
 // Macro to enable bitmask operations on an enum.  Without this, Enum | Enum
 // gets promoted to an int, so you have to say Enum a = Enum(eFoo | eBar).  If



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


[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)

2024-10-10 Thread Igor Kudrin via lldb-commits

igorkudrin wrote:

So the test basically shows that it makes sense to set `use-source-cache` to 
`false` on Windows, otherwise the source file will be locked for editing. 
Windows 11 seems to allow deleting mmaped files, so we need to try opening the 
file for writing to re-enable the test. Thanks, @emrekultursay.

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


[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)

2024-10-10 Thread Igor Kudrin via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb] Move SBLanguages.h out of API tree (PR #111929)

2024-10-10 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

> This looks better to me. I'm not sure why we were using defines from 
> llvm::DWARF that seem to overlap the ones here, however. So I'll defer to 
> Adrian or someone more knowledgeable about that side of things.

Yeah, that wasn't clear to me either, why didn't we just use the types in 
`llvm::dwarf::SourceLanguageName` and had to generate a new enum from the same 
table-gen file. @adrian-prantl any guesses ?

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


[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)

2024-10-10 Thread Emre Kultursay via lldb-commits

emrekultursay wrote:

LGTM. Thanks. 

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-10-10 Thread Augusto Noronha via lldb-commits

augusto2112 wrote:

I reverted both this commit and also 
https://github.com/llvm/llvm-project/commit/b77fdf5799be6b29869f2f7969851709e03938ba,
 so you'll need to add that change to your commit before merging again.

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


[Lldb-commits] [lldb] [lldb] Log errors to the system log if they would otherwise get dropped (PR #111911)

2024-10-10 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl approved this pull request.


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


[Lldb-commits] [lldb] [lldb] Add include for SBLanguages in lldb-enumerations (PR #111907)

2024-10-10 Thread via lldb-commits

jimingham wrote:



> On Oct 10, 2024, at 4:14 PM, Alex Langford ***@***.***> wrote:
> 
> 
> My mental model is that everything in lldb-enumerations.h should be public 
> and all the private enumerations should go in lldb-private-enumerations.h. In 
> practice I think there are tons of things in lldb-enumerations.h that should 
> not be public at all, but I'm not sure which are safe to remove since they're 
> all exposed through the Python bindings.
> 
I agree with that, but the argument here was going the other way.  
lldb-enumerations.h are a base set of enumerations that anybody using LLDB, 
either lldb_private or the SB API's are free to use.  But the SB API's are 
purely wrappers around lldb_private API's, and so should never be used in 
lldb_private.  If you put an SB API header in lldb-enumerations.h, now most of 
lldb_private is going to see it.  

Does that also fit wth your mental model?

Jim

> —
> Reply to this email directly, view it on GitHub 
> , 
> or unsubscribe 
> .
> You are receiving this because you were mentioned.
> 



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


[Lldb-commits] [lldb] Support inline diagnostics in CommandReturnObject (PR #110901)

2024-10-10 Thread Adrian Prantl via lldb-commits

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

>From e13c841a6452ae5b0cfae129764dc95d6ac29e09 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Wed, 9 Oct 2024 09:45:53 -0700
Subject: [PATCH] Support inline diagnostics in CommandReturnObject

and implement them for dwim-print (a.k.a. `p`) and the command option
parser (in one place thus far) as an example.

The next step will be to expose them as structured data in
SBCommandReturnObject.
---
 .../lldb/Expression/DiagnosticManager.h   | 38 ++
 .../lldb/Interpreter/CommandReturnObject.h| 21 --
 lldb/include/lldb/Utility/Args.h  |  6 +-
 .../lldb/Utility/DiagnosticsRendering.h   | 75 +++
 lldb/include/lldb/Utility/Status.h| 12 +--
 .../Commands/CommandObjectDWIMPrint.cpp   |  9 +++
 .../Commands/CommandObjectExpression.cpp  |  5 +-
 lldb/source/Expression/DiagnosticManager.cpp  |  4 +-
 lldb/source/Expression/FunctionCaller.cpp |  4 +-
 lldb/source/Expression/LLVMUserExpression.cpp |  4 +-
 .../source/Interpreter/CommandInterpreter.cpp | 22 +-
 lldb/source/Interpreter/CommandObject.cpp | 11 +--
 .../Interpreter/CommandReturnObject.cpp   | 36 -
 lldb/source/Interpreter/Options.cpp   | 49 +++-
 lldb/source/Utility/Args.cpp  | 41 ++
 lldb/source/Utility/CMakeLists.txt|  1 +
 .../DiagnosticsRendering.cpp} | 59 ++-
 lldb/source/Utility/Status.cpp| 31 
 .../Shell/Commands/command-dwim-print.test| 16 
 lldb/test/Shell/Commands/command-options.test | 16 
 lldb/unittests/Interpreter/CMakeLists.txt |  1 -
 lldb/unittests/Utility/CMakeLists.txt |  1 +
 .../DiagnosticsRenderingTest.cpp} |  6 +-
 23 files changed, 322 insertions(+), 146 deletions(-)
 create mode 100644 lldb/include/lldb/Utility/DiagnosticsRendering.h
 rename lldb/source/{Commands/DiagnosticRendering.h => 
Utility/DiagnosticsRendering.cpp} (70%)
 create mode 100644 lldb/test/Shell/Commands/command-dwim-print.test
 create mode 100644 lldb/test/Shell/Commands/command-options.test
 rename lldb/unittests/{Interpreter/TestCommandObjectExpression.cpp => 
Utility/DiagnosticsRenderingTest.cpp} (84%)

diff --git a/lldb/include/lldb/Expression/DiagnosticManager.h 
b/lldb/include/lldb/Expression/DiagnosticManager.h
index b9a6421577781e..cc802b6f48334a 100644
--- a/lldb/include/lldb/Expression/DiagnosticManager.h
+++ b/lldb/include/lldb/Expression/DiagnosticManager.h
@@ -12,6 +12,7 @@
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-types.h"
 
+#include "lldb/Utility/DiagnosticsRendering.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 
@@ -23,49 +24,22 @@
 
 namespace lldb_private {
 
-/// A compiler-independent representation of a Diagnostic. Expression
-/// evaluation failures often have more than one diagnostic that a UI
-/// layer might want to render differently, for example to colorize
-/// it.
-///
-/// Running example:
-///   (lldb) expr 1+foo
-///   error: :1:3: use of undeclared identifier 'foo'
-///   1+foo
-/// ^
-struct DiagnosticDetail {
-  struct SourceLocation {
-FileSpec file;
-unsigned line = 0;
-uint16_t column = 0;
-uint16_t length = 0;
-bool hidden = false;
-bool in_user_input = false;
-  };
-  /// Contains {{}, 1, 3, 3, true} in the example above.
-  std::optional source_location;
-  /// Contains eSeverityError in the example above.
-  lldb::Severity severity = lldb::eSeverityInfo;
-  /// Contains "use of undeclared identifier 'x'" in the example above.
-  std::string message;
-  /// Contains the fully rendered error message.
-  std::string rendered;
-};
-
 /// An llvm::Error used to communicate diagnostics in Status. Multiple
 /// diagnostics may be chained in an llvm::ErrorList.
 class ExpressionError
-: public llvm::ErrorInfo {
+: public llvm::ErrorInfo {
   std::string m_message;
   std::vector m_details;
 
 public:
   static char ID;
-  using llvm::ErrorInfo::ErrorInfo;
+  using llvm::ErrorInfo::ErrorInfo;
   ExpressionError(lldb::ExpressionResults result, std::string msg,
   std::vector details = {});
   std::string message() const override;
-  llvm::ArrayRef GetDetails() const { return m_details; }
+  llvm::ArrayRef GetDetails() const override {
+return m_details;
+  }
   std::error_code convertToErrorCode() const override;
   void log(llvm::raw_ostream &OS) const override;
   std::unique_ptr Clone() const override;
diff --git a/lldb/include/lldb/Interpreter/CommandReturnObject.h 
b/lldb/include/lldb/Interpreter/CommandReturnObject.h
index 8f6c9f123b7690..e13c3b7b8e0437 100644
--- a/lldb/include/lldb/Interpreter/CommandReturnObject.h
+++ b/lldb/include/lldb/Interpreter/CommandReturnObject.h
@@ -10,6 +10,7 @@
 #define LLDB_INTERPRETER_COMMANDRETURNOBJECT_H
 
 #include "lldb/Host/StreamFile.h"
+#include "lldb/Utility/Diagnostics

[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)

2024-10-10 Thread Igor Kudrin via lldb-commits

https://github.com/igorkudrin updated 
https://github.com/llvm/llvm-project/pull/111237

>From 6756842b1c78ac6f41fa467f112aa7632f260582 Mon Sep 17 00:00:00 2001
From: Igor Kudrin 
Date: Fri, 4 Oct 2024 23:27:04 -0700
Subject: [PATCH 1/2] [lldb] Fix and re-enable TestUseSourceCache.py

The decorators caused the main test, i.e. `test_set_use_source_cache_true()`,
to be skipped in most scenarios. In fact, it was only run on a Windows host
targeting a non-Windows remote platform, and it failed in this case because
the source file is opened with the `FILE_SHARE_DELETE` share mode, which
allows the file to be removed, see `llvm::sys::fs::openNativeFileInternal()`
in `llvm/lib/Support/Windows/Path.inc`.

This patch changes the test to check that the content can still be displayed
even after deleting the file when caching is enabled. The updated test is
expected to work on any platform, so the decorators are removed.
---
 .../settings/use_source_cache/TestUseSourceCache.py   | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git 
a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py 
b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
index 421599080a9e51..421b13f253f05b 100644
--- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
+++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
@@ -17,8 +17,6 @@ def test_set_use_source_cache_false(self):
 """Test that after 'set use-source-cache false', files are not 
locked."""
 self.set_use_source_cache_and_test(False)
 
-@skipIf(hostoslist=no_match(["windows"]))
-@skipIf(oslist=["windows"])  # Fails on windows 11
 def test_set_use_source_cache_true(self):
 """Test that after 'set use-source-cache false', files are locked."""
 self.set_use_source_cache_and_test(True)
@@ -43,16 +41,15 @@ def set_use_source_cache_and_test(self, is_cache_enabled):
 self, "calc"
 )
 
-# Show the source file contents to make sure LLDB loads src file.
-self.runCmd("source list")
+# Ensure that the source file is loaded.
+self.expect("step", patterns=["-> .+ int x4 ="])
 
 # Try deleting the source file.
 is_file_removed = self.removeFile(src)
 
 if is_cache_enabled:
-self.assertFalse(
-is_file_removed, "Source cache is enabled, but delete file 
succeeded"
-)
+# Regardless of whether the file is removed, its contents should 
be displayed.
+self.expect("step", patterns=["-> .+ int x5 ="])
 
 if not is_cache_enabled:
 self.assertTrue(

>From ef848fd2c7de9483cfe2cb0286a20df0a2005f97 Mon Sep 17 00:00:00 2001
From: Igor Kudrin 
Date: Tue, 8 Oct 2024 22:16:23 -0700
Subject: [PATCH 2/2] `removeFile()` -> `overwriteFile()`

---
 .../use_source_cache/TestUseSourceCache.py| 26 +++
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git 
a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py 
b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
index 421b13f253f05b..0c005ff3ab21b1 100644
--- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
+++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
@@ -17,8 +17,9 @@ def test_set_use_source_cache_false(self):
 """Test that after 'set use-source-cache false', files are not 
locked."""
 self.set_use_source_cache_and_test(False)
 
+@skipIf(hostoslist=no_match(["windows"]))
 def test_set_use_source_cache_true(self):
-"""Test that after 'set use-source-cache false', files are locked."""
+"""Test that after 'set use-source-cache true', files are locked."""
 self.set_use_source_cache_and_test(True)
 
 def set_use_source_cache_and_test(self, is_cache_enabled):
@@ -41,25 +42,28 @@ def set_use_source_cache_and_test(self, is_cache_enabled):
 self, "calc"
 )
 
-# Ensure that the source file is loaded.
-self.expect("step", patterns=["-> .+ int x4 ="])
+# Show the source file contents to make sure LLDB loads src file.
+self.runCmd("source list")
 
-# Try deleting the source file.
-is_file_removed = self.removeFile(src)
+# Try overwriting the source file.
+is_file_overwritten = self.overwriteFile(src)
 
 if is_cache_enabled:
-# Regardless of whether the file is removed, its contents should 
be displayed.
-self.expect("step", patterns=["-> .+ int x5 ="])
+self.assertFalse(
+is_file_overwritten, "Source cache is enabled, but writing to 
file succeeded"
+)
 
 if not is_cache_enabled:
 self.assertTrue(
-is_file_removed, "Source cache is disabled, but delete file 
failed"
+is_file_overwritten, "Source cache is 

[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)

2024-10-10 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
1809d0fa1c15b16ca94381d8be3ef70c4a83c36b...ef848fd2c7de9483cfe2cb0286a20df0a2005f97
 lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
``





View the diff from darker here.


``diff
--- TestUseSourceCache.py   2024-10-10 21:58:04.00 +
+++ TestUseSourceCache.py   2024-10-10 22:03:32.727149 +
@@ -48,16 +48,18 @@
 # Try overwriting the source file.
 is_file_overwritten = self.overwriteFile(src)
 
 if is_cache_enabled:
 self.assertFalse(
-is_file_overwritten, "Source cache is enabled, but writing to 
file succeeded"
+is_file_overwritten,
+"Source cache is enabled, but writing to file succeeded",
 )
 
 if not is_cache_enabled:
 self.assertTrue(
-is_file_overwritten, "Source cache is disabled, but writing to 
file failed"
+is_file_overwritten,
+"Source cache is disabled, but writing to file failed",
 )
 
 def overwriteFile(self, src):
 """Write to file and return true iff file was successfully written."""
 try:

``




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


[Lldb-commits] [lldb] [LLDB]Provide clearer error message for invalid commands. (PR #111891)

2024-10-10 Thread Jonas Devlieghere via lldb-commits


@@ -194,28 +194,50 @@ void CommandObjectMultiword::Execute(const char 
*args_string,
 
   std::string error_msg;
   const size_t num_subcmd_matches = matches.GetSize();
-  if (num_subcmd_matches > 0)
+  if (num_subcmd_matches > 0) {
 error_msg.assign("ambiguous command ");
-  else
-error_msg.assign("invalid command ");
-
-  error_msg.append("'");
-  error_msg.append(std::string(GetCommandName()));
-  error_msg.append(" ");
-  error_msg.append(std::string(sub_command));
-  error_msg.append("'.");
+error_msg.append("'");
+error_msg.append(std::string(GetCommandName()));
+error_msg.append(" ");
+error_msg.append(std::string(sub_command));
+error_msg.append("'.");
 
-  if (num_subcmd_matches > 0) {
 error_msg.append(" Possible completions:");
 for (const std::string &match : matches) {
   error_msg.append("\n\t");
   error_msg.append(match);
 }
+  } else {
+// Rather than simply complaining about the invalid (sub) command,
+// try to offer some alternatives.
+// This is especially useful for cases where the user types something
+// seamingly trivial, such as `breakpoint foo`.
+error_msg.assign(
+llvm::Twine("'" + sub_command + "' is not a valid subcommand of \"" +
+GetCommandName() + "\". Valid subcommands are " +
+GetTopSubcommands(/*count=*/5) + ". Use \"help " +
+GetCommandName() + "\" to find out more.")
+.str());
   }
   error_msg.append("\n");
   result.AppendRawError(error_msg.c_str());
 }
 
+std::string CommandObjectMultiword::GetTopSubcommands(int count) {
+  if (m_subcommand_dict.empty())
+return "";
+  std::string buffer = "{";
+  CommandMap::iterator pos;
+  for (pos = m_subcommand_dict.begin();
+   pos != m_subcommand_dict.end() && count > 0; ++pos, --count) {
+buffer.append("'");
+buffer.append(pos->first);
+buffer.append("',");
+  }
+  buffer.append("...}");

JDevlieghere wrote:

Can this return something that feels more like natural language? By that I mean 
dropping the opening and closing braces, adding a space after the comma and 
maybe even dropping the single quotes. 

IIUC, this will also always print `...` even if there are say two subcommands 
and count was 3, which seems needlessly confusing. We should only append this 
if there are actually more commands that weren't printed. 

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


[Lldb-commits] [lldb] [lldb] Add include for SBLanguages in lldb-enumerations (PR #111907)

2024-10-10 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add include for SBLanguages in lldb-enumerations (PR #111907)

2024-10-10 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add include for SBLanguages in lldb-enumerations (PR #111907)

2024-10-10 Thread Alex Langford via lldb-commits

bulbazord wrote:

My mental model is that everything in `lldb-enumerations.h` should be public 
and all the private enumerations should go in `lldb-private-enumerations.h`. In 
practice I think there are tons of things in `lldb-enumerations.h` that should 
not be public at all, but I'm not sure which are safe to remove since they're 
all exposed through the Python bindings.

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


[Lldb-commits] [lldb] 4f32077 - Revert "[lldb] skip ReverseContinue tests on Darwin"

2024-10-10 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2024-10-10T16:24:38-07:00
New Revision: 4f320778148ba481881eb53ba065ed2a9d9bbc03

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

LOG: Revert "[lldb] skip ReverseContinue tests on Darwin"

This reverts commit c686eeb7fcc89673909e7e1f0a0a09a0da269d28.

Added: 


Modified: 

lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py

lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
 
b/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
index 8b53d86704f119..b37578fbd82468 100644
--- 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
+++ 
b/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
@@ -11,11 +11,9 @@
 class TestReverseContinueBreakpoints(ReverseTestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
-@skipIfDarwin # No Darwin ProcessNative impl for lldb-server
 def test_reverse_continue(self):
 self.reverse_continue_internal(async_mode=False)
 
-@skipIfDarwin # No Darwin ProcessNative impl for lldb-server
 def test_reverse_continue_async(self):
 self.reverse_continue_internal(async_mode=True)
 
@@ -39,11 +37,9 @@ def reverse_continue_internal(self, async_mode):
 self.assertState(process.GetState(), lldb.eStateExited)
 self.assertEqual(process.GetExitStatus(), 0)
 
-@skipIfDarwin # No Darwin ProcessNative impl for lldb-server
 def test_reverse_continue_breakpoint(self):
 self.reverse_continue_breakpoint_internal(async_mode=False)
 
-@skipIfDarwin # No Darwin ProcessNative impl for lldb-server
 def test_reverse_continue_breakpoint_async(self):
 self.reverse_continue_breakpoint_internal(async_mode=True)
 
@@ -58,11 +54,9 @@ def reverse_continue_breakpoint_internal(self, async_mode):
 threads_now = lldbutil.get_threads_stopped_at_breakpoint(process, 
trigger_bkpt)
 self.assertEqual(threads_now, initial_threads)
 
-@skipIfDarwin # No Darwin ProcessNative impl for lldb-server
 def test_reverse_continue_skip_breakpoint(self):
 self.reverse_continue_skip_breakpoint_internal(async_mode=False)
 
-@skipIfDarwin # No Darwin ProcessNative impl for lldb-server
 def test_reverse_continue_skip_breakpoint_async(self):
 self.reverse_continue_skip_breakpoint_internal(async_mode=True)
 

diff  --git 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
 
b/lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
index 8a20f0ffdcf660..d610761b8cb0bc 100644
--- 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
+++ 
b/lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
@@ -8,7 +8,6 @@
 class TestReverseContinueNotSupported(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
-@skipIfDarwin # No Darwin ProcessNative impl for lldb-server
 def test_reverse_continue_not_supported(self):
 self.build()
 exe = self.getBuildArtifact("a.out")



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


[Lldb-commits] [lldb] a28e7ce - Revert "[lldb] SetErrorStringWithFormatv -> FromErrorStringWithFormatv (NFC)"

2024-10-10 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2024-10-10T16:24:38-07:00
New Revision: a28e7ce378d717e6aacbdc3089974b93b6b62948

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

LOG: Revert "[lldb] SetErrorStringWithFormatv -> FromErrorStringWithFormatv 
(NFC)"

This reverts commit fae7d6848bbb59fc2bad17adbdb34bd6a11a0651.

Added: 


Modified: 
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp 
b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index 367fce442bb866..116c43343c01d1 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -407,9 +407,8 @@ Status ProcessKDP::DoResume(RunDirection direction) {
   Log *log = GetLog(KDPLog::Process);
 
   if (direction == RunDirection::eRunReverse) {
-error.FromErrorStringWithFormatv(
-"error: {0} does not support reverse execution of processes",
-GetPluginName());
+error.SetErrorStringWithFormatv(
+"error: {0} does not support reverse execution of processes", 
GetPluginName());
 return error;
   }
 



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


[Lldb-commits] [lldb] [llvm] [lldb] Move SBLanguages.h out of API tree (PR #111929)

2024-10-10 Thread Chelsea Cassanova via lldb-commits


@@ -5,22 +5,21 @@
 import os
 
 HEADER = """\
-//===-- SBLanguages.h -*- C++ -*-===//
+//===-- SourceLanguageNames.h ---*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 
//===--===//
 
-#ifndef LLDB_API_SBLANGUAGE_H
-#define LLDB_API_SBLANGUAGE_H
+#ifndef LLDB_SOURCELANGUAGENAMES_H
+#define LLDB_SOURCELANGUAGENAMES_H
 
 namespace lldb {
-/// Used by \\ref SBExpressionOptions.
 /// These enumerations use the same language enumerations as the DWARF

chelcassanova wrote:

This is a nit but maybe we want to add that this file is generated and that 
there's a reason this enum isn't directly implemented in `lldb-enumerations.h`?

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


[Lldb-commits] [lldb] [llvm] [lldb] Move SBLanguages.h out of API tree (PR #111929)

2024-10-10 Thread Chelsea Cassanova via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb] Move SBLanguages.h out of API tree (PR #111929)

2024-10-10 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova commented:

This looks good to me and I agree with the original feedback that led to this 
change in the first place, though I'll also wait for any comments Adrian might 
have.

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


[Lldb-commits] [lldb] 4f29756 - [lldb] Implement basic support for reverse-continue (#99736)

2024-10-10 Thread Jason Molenda via lldb-commits

Author: Robert O'Callahan
Date: 2024-10-10T16:08:19-07:00
New Revision: 4f297566b3150097de26c6a23a987d2bd5fc19c5

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

LOG: [lldb] Implement basic support for reverse-continue (#99736)

This commit only adds support for the
`SBProcess::ReverseContinue()` API. A user-accessible command for this
will follow in a later commit.

This feature depends on a gdbserver implementation (e.g. `rr`) providing
support for the `bc` and `bs` packets. `lldb-server` does not support
those packets, and there is no plan to change that. So, for testing
purposes, `lldbreverse.py` wraps `lldb-server` with a Python
implementation of *very limited* record-and-replay functionality for use
by *tests only*.

The majority of this PR is test infrastructure (about 700 of the 950
lines added).

Added: 
lldb/packages/Python/lldbsuite/test/lldbgdbproxy.py
lldb/packages/Python/lldbsuite/test/lldbreverse.py
lldb/test/API/functionalities/reverse-execution/Makefile

lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py

lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
lldb/test/API/functionalities/reverse-execution/main.c

Modified: 
lldb/include/lldb/API/SBProcess.h
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Target/StopInfo.h
lldb/include/lldb/lldb-enumerations.h
lldb/packages/Python/lldbsuite/test/gdbclientutils.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/source/API/SBProcess.cpp
lldb/source/API/SBThread.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedProcess.h
lldb/source/Target/Process.cpp
lldb/source/Target/StopInfo.cpp
lldb/source/Target/Thread.cpp
lldb/tools/lldb-dap/JSONUtils.cpp
lldb/tools/lldb-dap/LLDBUtils.cpp

Removed: 




diff  --git a/lldb/include/lldb/API/SBProcess.h 
b/lldb/include/lldb/API/SBProcess.h
index 1624e02070b1b2..8b8ed830b54cc0 100644
--- a/lldb/include/lldb/API/SBProcess.h
+++ b/lldb/include/lldb/API/SBProcess.h
@@ -159,6 +159,7 @@ class LLDB_API SBProcess {
   lldb::SBError Destroy();
 
   lldb::SBError Continue();
+  lldb::SBError Continue(RunDirection direction);
 
   lldb::SBError Stop();
 

diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index b8c53a474ba6b9..fe7fbc50fd5770 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -857,10 +857,10 @@ class Process : public 
std::enable_shared_from_this,
   /// \see Thread:Resume()
   /// \see Thread:Step()
   /// \see Thread:Suspend()
-  Status Resume();
+  Status Resume(lldb::RunDirection direction = lldb::eRunForward);
 
   /// Resume a process, and wait for it to stop.
-  Status ResumeSynchronous(Stream *stream);
+  Status ResumeSynchronous(Stream *stream, lldb::RunDirection direction = 
lldb::eRunForward);
 
   /// Halts a running process.
   ///
@@ -1104,9 +1104,14 @@ class Process : public 
std::enable_shared_from_this,
   /// \see Thread:Resume()
   /// \see Thread:Step()
   /// \see Thread:Suspend()
-  virtual Status DoResume() {
-return Status::FromErrorStringWithFormatv(
-"error: {0} does not support resuming processes", GetPluginName());
+  virtual Status DoResume(lldb::RunDirection direction) {
+if (direction == lldb::RunDirection::eRunForward) {
+  return Status::FromErrorStringWithFormatv(
+  "error: {0} does not support resuming processes", GetPluginName());
+} else {
+  return Status::FromErrorStringWithFormatv(
+  "error: {0} does not support reverse execution of processes", 
GetPluginName());
+}
   }
 
   /// Called after resuming a process.
@@ -2332,6 +2337,8 @@ class Process : public 
std::enable_shared_from_this,
 
   bool IsRunning() const;
 
+  lldb::RunDirection GetLastRunDirection() { return m_last_run_direction; }
+
   DynamicCheckerFunctions *GetDynamicCheckers() {
 return m_dynamic_checkers_up.get();
   }
@@ -2851,7 +2858,

[Lldb-commits] [lldb] [LLDB] FindLibCppStdFunctionCallableInfo improvements (PR #111892)

2024-10-10 Thread David Mentler via lldb-commits

https://github.com/mentlerd updated 
https://github.com/llvm/llvm-project/pull/111892

>From b1e6178b1130135262884d99262716fcc0ada86e Mon Sep 17 00:00:00 2001
From: David Mentler 
Date: Mon, 7 Oct 2024 21:46:50 +0200
Subject: [PATCH 1/7] Make existing tests break

---
 .../data-formatter-stl/libcxx/function/main.cpp| 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
index ef7c97470652fc..b17aba3fbbc70e 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/function/main.cpp
@@ -1,5 +1,10 @@
 #include 
 
+template
+struct Dummy {
+  // Used to make lambda host function's symbol more complex
+};
+
 int foo(int x, int y) {
   return x + y - 1;
 }
@@ -18,7 +23,7 @@ struct Bar {
}
 } ;
 
-int foo2() {
+int foo2(Dummy<> dummy = {}) {
auto f = [](int x) {
return x+1;
};

>From d976756f47781d58c0367835a56b5b8e9130191b Mon Sep 17 00:00:00 2001
From: David Mentler 
Date: Wed, 9 Oct 2024 20:40:03 +0200
Subject: [PATCH 2/7] Expose conversion from DeclContext to Decl

---
 lldb/include/lldb/Symbol/CompilerDeclContext.h   | 2 ++
 lldb/include/lldb/Symbol/TypeSystem.h| 4 
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 7 +++
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h   | 2 ++
 lldb/source/Symbol/CompilerDeclContext.cpp   | 6 ++
 5 files changed, 21 insertions(+)

diff --git a/lldb/include/lldb/Symbol/CompilerDeclContext.h 
b/lldb/include/lldb/Symbol/CompilerDeclContext.h
index 89b4a9787688bc..3954ddd8e52087 100644
--- a/lldb/include/lldb/Symbol/CompilerDeclContext.h
+++ b/lldb/include/lldb/Symbol/CompilerDeclContext.h
@@ -110,6 +110,8 @@ class CompilerDeclContext {
 
   ConstString GetScopeQualifiedName() const;
 
+  CompilerDecl GetDecl() const;
+
 private:
   TypeSystem *m_type_system = nullptr;
   void *m_opaque_decl_ctx = nullptr;
diff --git a/lldb/include/lldb/Symbol/TypeSystem.h 
b/lldb/include/lldb/Symbol/TypeSystem.h
index 7d48f9b316138c..4b531a83dd5fbb 100644
--- a/lldb/include/lldb/Symbol/TypeSystem.h
+++ b/lldb/include/lldb/Symbol/TypeSystem.h
@@ -134,6 +134,10 @@ class TypeSystem : public PluginInterface,
 
   virtual lldb::LanguageType DeclContextGetLanguage(void *opaque_decl_ctx) = 0;
 
+  virtual CompilerDecl DeclContextGetDecl(void *opaque_decl_ctx) {
+return CompilerDecl();
+  }
+ 
   /// Returns the direct parent context of specified type
   virtual CompilerDeclContext
   GetCompilerDeclContextForType(const CompilerType &type);
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index fe0c53a7e9a3ea..678ac8d65331b7 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -9595,6 +9595,13 @@ TypeSystemClang::DeclContextGetLanguage(void 
*opaque_decl_ctx) {
   return eLanguageTypeUnknown;
 }
 
+CompilerDecl TypeSystemClang::DeclContextGetDecl(void *opaque_decl_ctx) {
+  if (auto *decl_ctx = (clang::DeclContext *)opaque_decl_ctx)
+if (auto* decl = dyn_cast_or_null(decl_ctx))
+  return CompilerDecl(this, decl);
+  return CompilerDecl();
+}
+
 static bool IsClangDeclContext(const CompilerDeclContext &dc) {
   return dc.IsValid() && isa(dc.GetTypeSystem());
 }
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
index e39aedec7e3902..e7ac6e320f20b7 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
@@ -595,6 +595,8 @@ class TypeSystemClang : public TypeSystem {
 
   lldb::LanguageType DeclContextGetLanguage(void *opaque_decl_ctx) override;
 
+  CompilerDecl DeclContextGetDecl(void *opaque_decl_ctx) override;
+
   std::vector
   DeclContextGetCompilerContext(void *opaque_decl_ctx) override;
 
diff --git a/lldb/source/Symbol/CompilerDeclContext.cpp 
b/lldb/source/Symbol/CompilerDeclContext.cpp
index b40a08e9b1953d..7a72c4301b0b5c 100644
--- a/lldb/source/Symbol/CompilerDeclContext.cpp
+++ b/lldb/source/Symbol/CompilerDeclContext.cpp
@@ -34,6 +34,12 @@ ConstString CompilerDeclContext::GetScopeQualifiedName() 
const {
   return ConstString();
 }
 
+CompilerDecl CompilerDeclContext::GetDecl() const {
+  if (IsValid())
+return m_type_system->DeclContextGetDecl(m_opaque_decl_ctx);
+  return CompilerDecl();
+}
+
 bool CompilerDeclContext::IsClassMethod() {
   if (IsValid())
 return m_type_system->DeclContextIsClassMethod(m_opaque_decl_ctx);

>From 2e75bb0aac608d626fba5878315e9118bfcf9c8a Mon Sep 17 00:00:00 2001
From: David Mentler 
Date: Wed, 9 Oct 2024 20:41:04

[Lldb-commits] [lldb] fae7d68 - [lldb] SetErrorStringWithFormatv -> FromErrorStringWithFormatv (NFC)

2024-10-10 Thread Jason Molenda via lldb-commits

Author: Jonas Devlieghere
Date: 2024-10-10T16:08:19-07:00
New Revision: fae7d6848bbb59fc2bad17adbdb34bd6a11a0651

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

LOG: [lldb] SetErrorStringWithFormatv -> FromErrorStringWithFormatv (NFC)

Added: 


Modified: 
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp 
b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index 116c43343c01d1..367fce442bb866 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -407,8 +407,9 @@ Status ProcessKDP::DoResume(RunDirection direction) {
   Log *log = GetLog(KDPLog::Process);
 
   if (direction == RunDirection::eRunReverse) {
-error.SetErrorStringWithFormatv(
-"error: {0} does not support reverse execution of processes", 
GetPluginName());
+error.FromErrorStringWithFormatv(
+"error: {0} does not support reverse execution of processes",
+GetPluginName());
 return error;
   }
 



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


[Lldb-commits] [lldb] c686eeb - [lldb] skip ReverseContinue tests on Darwin

2024-10-10 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2024-10-10T16:08:19-07:00
New Revision: c686eeb7fcc89673909e7e1f0a0a09a0da269d28

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

LOG: [lldb] skip ReverseContinue tests on Darwin

This uses lldb-server in gdbserver mode, which requires a ProcessNative
plugin.  Darwin does not have a ProcessNative plugin; it uses
debugserver instead of lldb-server.  Skip these tests.

Added: 


Modified: 

lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py

lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
 
b/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
index b37578fbd82468..8b53d86704f119 100644
--- 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
+++ 
b/lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
@@ -11,9 +11,11 @@
 class TestReverseContinueBreakpoints(ReverseTestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
+@skipIfDarwin # No Darwin ProcessNative impl for lldb-server
 def test_reverse_continue(self):
 self.reverse_continue_internal(async_mode=False)
 
+@skipIfDarwin # No Darwin ProcessNative impl for lldb-server
 def test_reverse_continue_async(self):
 self.reverse_continue_internal(async_mode=True)
 
@@ -37,9 +39,11 @@ def reverse_continue_internal(self, async_mode):
 self.assertState(process.GetState(), lldb.eStateExited)
 self.assertEqual(process.GetExitStatus(), 0)
 
+@skipIfDarwin # No Darwin ProcessNative impl for lldb-server
 def test_reverse_continue_breakpoint(self):
 self.reverse_continue_breakpoint_internal(async_mode=False)
 
+@skipIfDarwin # No Darwin ProcessNative impl for lldb-server
 def test_reverse_continue_breakpoint_async(self):
 self.reverse_continue_breakpoint_internal(async_mode=True)
 
@@ -54,9 +58,11 @@ def reverse_continue_breakpoint_internal(self, async_mode):
 threads_now = lldbutil.get_threads_stopped_at_breakpoint(process, 
trigger_bkpt)
 self.assertEqual(threads_now, initial_threads)
 
+@skipIfDarwin # No Darwin ProcessNative impl for lldb-server
 def test_reverse_continue_skip_breakpoint(self):
 self.reverse_continue_skip_breakpoint_internal(async_mode=False)
 
+@skipIfDarwin # No Darwin ProcessNative impl for lldb-server
 def test_reverse_continue_skip_breakpoint_async(self):
 self.reverse_continue_skip_breakpoint_internal(async_mode=True)
 

diff  --git 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
 
b/lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
index d610761b8cb0bc..8a20f0ffdcf660 100644
--- 
a/lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
+++ 
b/lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
@@ -8,6 +8,7 @@
 class TestReverseContinueNotSupported(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
+@skipIfDarwin # No Darwin ProcessNative impl for lldb-server
 def test_reverse_continue_not_supported(self):
 self.build()
 exe = self.getBuildArtifact("a.out")



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


[Lldb-commits] [lldb] [lldb] Add include for SBLanguages in lldb-enumerations (PR #111907)

2024-10-10 Thread Chelsea Cassanova via lldb-commits

chelcassanova wrote:

I was going to fix the dependency issue here to make sure that SBLanguages gets 
generated before trying to build any of these targets, but talking with 
@jimingham, this shouldn't have been included at all as `lldb-enumerations` 
shouldn't be exposed to any SB layer components whatsoever.

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


[Lldb-commits] [lldb] [lldb] Add include for SBLanguages in lldb-enumerations (PR #111907)

2024-10-10 Thread via lldb-commits

https://github.com/jimingham commented:

This layering seems wrong to me.  If you put an SB header in 
lldb-enumerations.h, then you are pretty much including it in all of lldb.  But 
SB defines should really only be used in include/lldb/API and source/API.
Note, SBLanguages.h itself seems wrong to me.  It is used to pass a language 
name enum to SBExpressionOptions::SetLanguage, which turns around and calls 
EvaluateExpressionOptions::SetLanguage, but in that API we call it a uint16_t.  
Why didn't we make an lldb-languages.h and include that in some place that both 
the SB caller and the lldb API it wraps can share it on the up-and-up?

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


[Lldb-commits] [lldb] [lldb] Add include for SBLanguages in lldb-enumerations (PR #111907)

2024-10-10 Thread via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb] Move SBLanguages.h out of API tree (PR #111929)

2024-10-10 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben created 
https://github.com/llvm/llvm-project/pull/111929

This patch moves `SBLanguages.h` out of the API tree. This file gets generated 
at build time using DWARF table-gen file and contains an enumeration of the 
DWARF supported source language names and there respective code/identifier.

Since this is an enum, this shouldn't be part of the API tree but rather it 
should be included in the `lldb-enumeration` header.

Also, that enum was used in internal methods in `lldb_private` by down-casting 
the enum value type to an `uint16_t`. This patch changes that by making those 
internal methods use the enum type.

This should address the feedbacks from #111907.

>From 1e402543081d25ba40add8494938920d295495f4 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Thu, 10 Oct 2024 17:01:46 -0700
Subject: [PATCH] [lldb] Move SBLanguages.h out of API tree

This patch moves `SBLanguages.h` out of the API tree. This file gets
generated at build time using DWARF table-gen file and contains an
enumeration of the DWARF supported source language names and there
respective code/identifier.

Since this is an enum, this shouldn't be part of the API tree but rather
it should be included in the `lldb-enumeration` header.

Also, that enum was used in internal methods in `lldb_private` by
down-casting the enum value type to an `uint16_t`.
This patch changes that by making those internal methods use the enum
type.

This should address the feedbacks from #111907.

Signed-off-by: Med Ismail Bennani 
---
 lldb/bindings/CMakeLists.txt  |  2 +-
 lldb/bindings/headers.swig|  1 -
 lldb/bindings/interfaces.swig |  1 -
 lldb/cmake/modules/LLDBFramework.cmake|  2 +-
 lldb/include/lldb/API/LLDB.h  |  1 -
 lldb/include/lldb/API/SBExpressionOptions.h   |  3 +--
 lldb/include/lldb/Target/Target.h |  2 +-
 lldb/include/lldb/lldb-enumerations.h |  2 ++
 lldb/include/lldb/lldb-private-types.h| 11 +-
 lldb/scripts/generate-sbapi-dwarf-enum.py |  9 -
 lldb/source/API/CMakeLists.txt| 20 +--
 lldb/source/API/SBExpressionOptions.cpp   |  2 +-
 lldb/source/API/SBFrame.cpp   |  6 +++---
 .../Clang/ClangUserExpression.cpp | 13 
 lldb/source/Target/Language.cpp   | 19 ++
 .../lldb/include/lldb/{API => }/BUILD.gn  |  4 ++--
 .../llvm-project-overlay/lldb/BUILD.bazel |  2 +-
 17 files changed, 53 insertions(+), 47 deletions(-)
 rename llvm/utils/gn/secondary/lldb/include/lldb/{API => }/BUILD.gn (72%)

diff --git a/lldb/bindings/CMakeLists.txt b/lldb/bindings/CMakeLists.txt
index bec694e43bd7be..befc5c9e9afc15 100644
--- a/lldb/bindings/CMakeLists.txt
+++ b/lldb/bindings/CMakeLists.txt
@@ -3,7 +3,7 @@ file(GLOB_RECURSE SWIG_SOURCES *.swig)
 file(GLOB SWIG_HEADERS
   ${LLDB_SOURCE_DIR}/include/lldb/API/*.h
   ${LLDB_SOURCE_DIR}/include/lldb/*.h
-  ${LLDB_BINARY_DIR}/include/lldb/API/SBLanguages.h
+  ${LLDB_BINARY_DIR}/include/lldb/SourceLanguageNames.h
 )
 file(GLOB SWIG_PRIVATE_HEADERS
   ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h
diff --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig
index c0dde905f986bd..2420ea4aab843a 100644
--- a/lldb/bindings/headers.swig
+++ b/lldb/bindings/headers.swig
@@ -39,7 +39,6 @@
 #include "lldb/API/SBHostOS.h"
 #include "lldb/API/SBInstruction.h"
 #include "lldb/API/SBInstructionList.h"
-#include "lldb/API/SBLanguages.h"
 #include "lldb/API/SBLanguageRuntime.h"
 #include "lldb/API/SBLaunchInfo.h"
 #include "lldb/API/SBLineEntry.h"
diff --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
index 8a6fed95f0b729..e48e875367f7c4 100644
--- a/lldb/bindings/interfaces.swig
+++ b/lldb/bindings/interfaces.swig
@@ -120,7 +120,6 @@
 %include "lldb/API/SBHostOS.h"
 %include "lldb/API/SBInstruction.h"
 %include "lldb/API/SBInstructionList.h"
-%include "lldb/API/SBLanguages.h"
 %include "lldb/API/SBLanguageRuntime.h"
 %include "lldb/API/SBLaunchInfo.h"
 %include "lldb/API/SBLineEntry.h"
diff --git a/lldb/cmake/modules/LLDBFramework.cmake 
b/lldb/cmake/modules/LLDBFramework.cmake
index 471aeaaad3c0d3..0daff8b3e07e2b 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -71,7 +71,7 @@ endif()
 # At configuration time, collect headers for the framework bundle and copy them
 # into a staging directory. Later we can copy over the entire folder.
 file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
-set(generated_public_headers ${LLDB_OBJ_DIR}/include/lldb/API/SBLanguages.h)
+set(generated_public_headers 
${LLDB_OBJ_DIR}/include/lldb/SourceLanguageNames.h)
 file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
 file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
 list(REMOVE_ITEM root_public_headers ${root_private_headers})
diff --git a/l

[Lldb-commits] [lldb] [llvm] [lldb] Move SBLanguages.h out of API tree (PR #111929)

2024-10-10 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Med Ismail Bennani (medismailben)


Changes

This patch moves `SBLanguages.h` out of the API tree. This file gets generated 
at build time using DWARF table-gen file and contains an enumeration of the 
DWARF supported source language names and there respective code/identifier.

Since this is an enum, this shouldn't be part of the API tree but rather it 
should be included in the `lldb-enumeration` header.

Also, that enum was used in internal methods in `lldb_private` by down-casting 
the enum value type to an `uint16_t`. This patch changes that by making those 
internal methods use the enum type.

This should address the feedbacks from #111907.

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


17 Files Affected:

- (modified) lldb/bindings/CMakeLists.txt (+1-1) 
- (modified) lldb/bindings/headers.swig (-1) 
- (modified) lldb/bindings/interfaces.swig (-1) 
- (modified) lldb/cmake/modules/LLDBFramework.cmake (+1-1) 
- (modified) lldb/include/lldb/API/LLDB.h (-1) 
- (modified) lldb/include/lldb/API/SBExpressionOptions.h (+1-2) 
- (modified) lldb/include/lldb/Target/Target.h (+1-1) 
- (modified) lldb/include/lldb/lldb-enumerations.h (+2) 
- (modified) lldb/include/lldb/lldb-private-types.h (+6-5) 
- (modified) lldb/scripts/generate-sbapi-dwarf-enum.py (+4-5) 
- (modified) lldb/source/API/CMakeLists.txt (+10-10) 
- (modified) lldb/source/API/SBExpressionOptions.cpp (+1-1) 
- (modified) lldb/source/API/SBFrame.cpp (+3-3) 
- (modified) lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
(+9-4) 
- (modified) lldb/source/Target/Language.cpp (+11-8) 
- (renamed) llvm/utils/gn/secondary/lldb/include/lldb/BUILD.gn (+2-2) 
- (modified) utils/bazel/llvm-project-overlay/lldb/BUILD.bazel (+1-1) 


``diff
diff --git a/lldb/bindings/CMakeLists.txt b/lldb/bindings/CMakeLists.txt
index bec694e43bd7be..befc5c9e9afc15 100644
--- a/lldb/bindings/CMakeLists.txt
+++ b/lldb/bindings/CMakeLists.txt
@@ -3,7 +3,7 @@ file(GLOB_RECURSE SWIG_SOURCES *.swig)
 file(GLOB SWIG_HEADERS
   ${LLDB_SOURCE_DIR}/include/lldb/API/*.h
   ${LLDB_SOURCE_DIR}/include/lldb/*.h
-  ${LLDB_BINARY_DIR}/include/lldb/API/SBLanguages.h
+  ${LLDB_BINARY_DIR}/include/lldb/SourceLanguageNames.h
 )
 file(GLOB SWIG_PRIVATE_HEADERS
   ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h
diff --git a/lldb/bindings/headers.swig b/lldb/bindings/headers.swig
index c0dde905f986bd..2420ea4aab843a 100644
--- a/lldb/bindings/headers.swig
+++ b/lldb/bindings/headers.swig
@@ -39,7 +39,6 @@
 #include "lldb/API/SBHostOS.h"
 #include "lldb/API/SBInstruction.h"
 #include "lldb/API/SBInstructionList.h"
-#include "lldb/API/SBLanguages.h"
 #include "lldb/API/SBLanguageRuntime.h"
 #include "lldb/API/SBLaunchInfo.h"
 #include "lldb/API/SBLineEntry.h"
diff --git a/lldb/bindings/interfaces.swig b/lldb/bindings/interfaces.swig
index 8a6fed95f0b729..e48e875367f7c4 100644
--- a/lldb/bindings/interfaces.swig
+++ b/lldb/bindings/interfaces.swig
@@ -120,7 +120,6 @@
 %include "lldb/API/SBHostOS.h"
 %include "lldb/API/SBInstruction.h"
 %include "lldb/API/SBInstructionList.h"
-%include "lldb/API/SBLanguages.h"
 %include "lldb/API/SBLanguageRuntime.h"
 %include "lldb/API/SBLaunchInfo.h"
 %include "lldb/API/SBLineEntry.h"
diff --git a/lldb/cmake/modules/LLDBFramework.cmake 
b/lldb/cmake/modules/LLDBFramework.cmake
index 471aeaaad3c0d3..0daff8b3e07e2b 100644
--- a/lldb/cmake/modules/LLDBFramework.cmake
+++ b/lldb/cmake/modules/LLDBFramework.cmake
@@ -71,7 +71,7 @@ endif()
 # At configuration time, collect headers for the framework bundle and copy them
 # into a staging directory. Later we can copy over the entire folder.
 file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
-set(generated_public_headers ${LLDB_OBJ_DIR}/include/lldb/API/SBLanguages.h)
+set(generated_public_headers 
${LLDB_OBJ_DIR}/include/lldb/SourceLanguageNames.h)
 file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
 file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
 list(REMOVE_ITEM root_public_headers ${root_private_headers})
diff --git a/lldb/include/lldb/API/LLDB.h b/lldb/include/lldb/API/LLDB.h
index 40368e036e0e40..8884b21a40120f 100644
--- a/lldb/include/lldb/API/LLDB.h
+++ b/lldb/include/lldb/API/LLDB.h
@@ -42,7 +42,6 @@
 #include "lldb/API/SBInstruction.h"
 #include "lldb/API/SBInstructionList.h"
 #include "lldb/API/SBLanguageRuntime.h"
-#include "lldb/API/SBLanguages.h"
 #include "lldb/API/SBLaunchInfo.h"
 #include "lldb/API/SBLineEntry.h"
 #include "lldb/API/SBListener.h"
diff --git a/lldb/include/lldb/API/SBExpressionOptions.h 
b/lldb/include/lldb/API/SBExpressionOptions.h
index a9e929a4c0bd9d..490bdb982e8d6b 100644
--- a/lldb/include/lldb/API/SBExpressionOptions.h
+++ b/lldb/include/lldb/API/SBExpressionOptions.h
@@ -10,7 +10,6 @@
 #define LLDB_API_SBEXPRESSIONOPTIONS_H
 
 #include "lldb/API/SBDefines.h"
-#include "lldb/API/SBLanguages.h"
 
 #include 
 
@@ -71,

[Lldb-commits] [lldb] [lldb] Log errors to the system log if they would otherwise get dropped (PR #111911)

2024-10-10 Thread Jonas Devlieghere via lldb-commits

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

Log errors to the (always-on) system log if they would otherwise get dropped by 
LLDB_LOG_ERROR and LLDB_LOG_ERRORV.

>From 55eab57c695d4be99305d2b6cee0c4f44261a473 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Thu, 10 Oct 2024 14:39:44 -0700
Subject: [PATCH] [lldb] Log errors to the system log if they would otherwise
 get dropped

Log errors to the (always-on) system log if they would otherwise get
dropped by LLDB_LOG_ERROR and LLDB_LOG_ERRORV.
---
 lldb/include/lldb/Utility/Log.h   | 15 +++
 lldb/source/API/SystemInitializerFull.cpp |  3 +++
 lldb/source/Utility/Log.cpp   |  8 
 3 files changed, 26 insertions(+)

diff --git a/lldb/include/lldb/Utility/Log.h b/lldb/include/lldb/Utility/Log.h
index ac6347153a1014..f8545cd59a18ba 100644
--- a/lldb/include/lldb/Utility/Log.h
+++ b/lldb/include/lldb/Utility/Log.h
@@ -335,6 +335,15 @@ template  Log *GetLog(Cat mask) {
   return LogChannelFor().GetLog(Log::MaskType(mask));
 }
 
+/// Getter and setter for the error log (see g_error_log).
+/// The error log is set to the system log in SystemInitializerFull. We can't
+/// use the system log directly because that would violate the layering between
+/// Utility and Host.
+/// @{
+void SetLLDBErrorLog(Log *log);
+Log *GetLLDBErrorLog();
+/// @}
+
 } // namespace lldb_private
 
 /// The LLDB_LOG* macros defined below are the way to emit log messages.
@@ -387,6 +396,9 @@ template  Log *GetLog(Cat mask) {
 if (log_private && error_private) {
\
   log_private->FormatError(::std::move(error_private), __FILE__, __func__, 
\
__VA_ARGS__);   
\
+} else if (::lldb_private::Log *log_error = GetLLDBErrorLog()) {   
\
+  log_error->FormatError(::std::move(error_private), __FILE__, __func__,   
\
+ __VA_ARGS__); 
\
 } else 
\
   ::llvm::consumeError(::std::move(error_private));
\
   } while (0)
@@ -401,6 +413,9 @@ template  Log *GetLog(Cat mask) {
 if (log_private && log_private->GetVerbose() && error_private) {   
\
   log_private->FormatError(::std::move(error_private), __FILE__, __func__, 
\
__VA_ARGS__);   
\
+} else if (::lldb_private::Log *log_error = GetLLDBErrorLog()) {   
\
+  log_error->FormatError(::std::move(error_private), __FILE__, __func__,   
\
+ __VA_ARGS__); 
\
 } else 
\
   ::llvm::consumeError(::std::move(error_private));
\
   } while (0)
diff --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index 8a992a6889a91b..31f3a9f30b81f0 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -84,6 +84,9 @@ llvm::Error SystemInitializerFull::Initialize() {
   // Use the Debugger's LLDBAssert callback.
   SetLLDBAssertCallback(Debugger::AssertCallback);
 
+  // Use the system log to report errors that would otherwise get dropped.
+  SetLLDBErrorLog(GetLog(SystemLog::System));
+
   LLDB_LOG(GetLog(SystemLog::System), "{0}", GetVersion());
 
   return llvm::Error::success();
diff --git a/lldb/source/Utility/Log.cpp b/lldb/source/Utility/Log.cpp
index 3798f406476370..a57d415be033ba 100644
--- a/lldb/source/Utility/Log.cpp
+++ b/lldb/source/Utility/Log.cpp
@@ -43,6 +43,10 @@ char TeeLogHandler::ID;
 
 llvm::ManagedStatic Log::g_channel_map;
 
+// The error log is used by LLDB_LOG_ERROR and LLDB_LOG_ERRORV. If the given
+// log channel is not enabled, error messages are logged to the error log.
+static std::atomic g_error_log = nullptr;
+
 void Log::ForEachCategory(
 const Log::ChannelMap::value_type &entry,
 llvm::function_ref lambda) {
@@ -460,3 +464,7 @@ void TeeLogHandler::Emit(llvm::StringRef message) {
   m_first_log_handler->Emit(message);
   m_second_log_handler->Emit(message);
 }
+
+void lldb_private::SetLLDBErrorLog(Log *log) { g_error_log.exchange(log); }
+
+Log *lldb_private::GetLLDBErrorLog() { return g_error_log; }

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


[Lldb-commits] [lldb] [lldb] Log errors to the system log if they would otherwise get dropped (PR #111911)

2024-10-10 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Log errors to the (always-on) system log if they would otherwise get dropped by 
LLDB_LOG_ERROR and LLDB_LOG_ERRORV.

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


3 Files Affected:

- (modified) lldb/include/lldb/Utility/Log.h (+15) 
- (modified) lldb/source/API/SystemInitializerFull.cpp (+3) 
- (modified) lldb/source/Utility/Log.cpp (+8) 


``diff
diff --git a/lldb/include/lldb/Utility/Log.h b/lldb/include/lldb/Utility/Log.h
index ac6347153a1014..f8545cd59a18ba 100644
--- a/lldb/include/lldb/Utility/Log.h
+++ b/lldb/include/lldb/Utility/Log.h
@@ -335,6 +335,15 @@ template  Log *GetLog(Cat mask) {
   return LogChannelFor().GetLog(Log::MaskType(mask));
 }
 
+/// Getter and setter for the error log (see g_error_log).
+/// The error log is set to the system log in SystemInitializerFull. We can't
+/// use the system log directly because that would violate the layering between
+/// Utility and Host.
+/// @{
+void SetLLDBErrorLog(Log *log);
+Log *GetLLDBErrorLog();
+/// @}
+
 } // namespace lldb_private
 
 /// The LLDB_LOG* macros defined below are the way to emit log messages.
@@ -387,6 +396,9 @@ template  Log *GetLog(Cat mask) {
 if (log_private && error_private) {
\
   log_private->FormatError(::std::move(error_private), __FILE__, __func__, 
\
__VA_ARGS__);   
\
+} else if (::lldb_private::Log *log_error = GetLLDBErrorLog()) {   
\
+  log_error->FormatError(::std::move(error_private), __FILE__, __func__,   
\
+ __VA_ARGS__); 
\
 } else 
\
   ::llvm::consumeError(::std::move(error_private));
\
   } while (0)
@@ -401,6 +413,9 @@ template  Log *GetLog(Cat mask) {
 if (log_private && log_private->GetVerbose() && error_private) {   
\
   log_private->FormatError(::std::move(error_private), __FILE__, __func__, 
\
__VA_ARGS__);   
\
+} else if (::lldb_private::Log *log_error = GetLLDBErrorLog()) {   
\
+  log_error->FormatError(::std::move(error_private), __FILE__, __func__,   
\
+ __VA_ARGS__); 
\
 } else 
\
   ::llvm::consumeError(::std::move(error_private));
\
   } while (0)
diff --git a/lldb/source/API/SystemInitializerFull.cpp 
b/lldb/source/API/SystemInitializerFull.cpp
index 8a992a6889a91b..31f3a9f30b81f0 100644
--- a/lldb/source/API/SystemInitializerFull.cpp
+++ b/lldb/source/API/SystemInitializerFull.cpp
@@ -84,6 +84,9 @@ llvm::Error SystemInitializerFull::Initialize() {
   // Use the Debugger's LLDBAssert callback.
   SetLLDBAssertCallback(Debugger::AssertCallback);
 
+  // Use the system log to report errors that would otherwise get dropped.
+  SetLLDBErrorLog(GetLog(SystemLog::System));
+
   LLDB_LOG(GetLog(SystemLog::System), "{0}", GetVersion());
 
   return llvm::Error::success();
diff --git a/lldb/source/Utility/Log.cpp b/lldb/source/Utility/Log.cpp
index 3798f406476370..a57d415be033ba 100644
--- a/lldb/source/Utility/Log.cpp
+++ b/lldb/source/Utility/Log.cpp
@@ -43,6 +43,10 @@ char TeeLogHandler::ID;
 
 llvm::ManagedStatic Log::g_channel_map;
 
+// The error log is used by LLDB_LOG_ERROR and LLDB_LOG_ERRORV. If the given
+// log channel is not enabled, error messages are logged to the error log.
+static std::atomic g_error_log = nullptr;
+
 void Log::ForEachCategory(
 const Log::ChannelMap::value_type &entry,
 llvm::function_ref lambda) {
@@ -460,3 +464,7 @@ void TeeLogHandler::Emit(llvm::StringRef message) {
   m_first_log_handler->Emit(message);
   m_second_log_handler->Emit(message);
 }
+
+void lldb_private::SetLLDBErrorLog(Log *log) { g_error_log.exchange(log); }
+
+Log *lldb_private::GetLLDBErrorLog() { return g_error_log; }

``




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


[Lldb-commits] [lldb] Support inline diagnostics in CommandReturnObject (PR #110901)

2024-10-10 Thread Adrian Prantl via lldb-commits


@@ -0,0 +1,11 @@
+# RUN: echo quit | %lldb -o "log enable -x" \

adrian-prantl wrote:

Thanks! Indeed, there's bug there.

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


[Lldb-commits] [lldb] DynamicLoaderDarwin load images in parallel (PR #110439)

2024-10-10 Thread Dmitrii Galimzianov via lldb-commits

DmT021 wrote:

> I was playing with the performance in a couple of different scenarios. For 
> some reason that I haven't looked into, we're getting less parallelism when 
> many of the binaries are in the shared cache in lldb. Maybe there is locking 
> around the code which finds the binary in lldb's own shared cache, so when 9 
> threads try to do it at the same time, we have additional lock contention.

There is a lock_guard for `shared_module_list.m_modules_mutex` at the beginning 
of `ModuleList::GetSharedModule`. I instrumented loading Slack and that 
lock_guard is responsible for about 7% of the total time. Most of the time is 
spent on constructing ConstString.
Here's a flame graph. It's captured with "Record Waiting Threads" enabled so 
the locks are visible.
[lldb_parallel.svg.zip](https://github.com/user-attachments/files/17337125/lldb_parallel.svg.zip)



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


[Lldb-commits] [lldb] [lldb] Speed up FindInMemory tests (PR #111951)

2024-10-10 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
1809d0fa1c15b16ca94381d8be3ef70c4a83c36b...6ea11737a9edbf1a1be413c2eaa7075438effb05
 lldb/test/API/python_api/find_in_memory/TestFindInMemory.py 
lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py 
lldb/test/API/python_api/find_in_memory/address_ranges_helper.py
``





View the diff from darker here.


``diff
--- address_ranges_helper.py2024-10-11 05:32:07.00 +
+++ address_ranges_helper.py2024-10-11 05:43:44.147378 +
@@ -25,23 +25,23 @@
 addr_ranges.Append(GetStackRange(test_base))
 return addr_ranges
 
 
 def GetRangeFromAddrValue(test_base, addr, shrink=False):
-""" Return the address range containing 'addr'.
-If 'shrink' is True, the size of the region will not exceed 2K.
+"""Return the address range containing 'addr'.
+If 'shrink' is True, the size of the region will not exceed 2K.
 """
 region = lldb.SBMemoryRegionInfo()
 test_base.assertTrue(
 test_base.process.GetMemoryRegionInfo(
 addr.GetValueAsUnsigned(), region
 ).Success(),
 )
 
 test_base.assertTrue(region.IsReadable())
 test_base.assertFalse(region.IsExecutable())
-
+
 base = region.GetRegionBase()
 end = region.GetRegionEnd()
 
 if shrink:
 addr2 = addr.GetValueAsUnsigned()

``




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


[Lldb-commits] [lldb] [lldb] Speed up FindInMemory tests (PR #111951)

2024-10-10 Thread Igor Kudrin via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Speed up FindInMemory tests (PR #111951)

2024-10-10 Thread Igor Kudrin via lldb-commits

https://github.com/igorkudrin updated 
https://github.com/llvm/llvm-project/pull/111951

>From e027444340be4020002126da0d2c8a705c2c7e3f Mon Sep 17 00:00:00 2001
From: Igor Kudrin 
Date: Thu, 10 Oct 2024 20:27:10 -0700
Subject: [PATCH] [lldb] Speed up FindInMemory tests

A memory region can be relatively large. Searching for a value in the
entire region is time-consuming, especially when running tests against
a remote target, because the memory data is transferred in small chunks
over a relatively slow GDB Remote Protocol. The patch limits the address
range to be searched to 2K, which seems sufficient for these tests. In
my setup, for local runs, these tests now take half the time they did
before the patch. For a remote target, the improvement is even more
significant.
---
 .../find_in_memory/TestFindInMemory.py| 10 ++--
 .../find_in_memory/TestFindRangesInMemory.py  | 16 +++---
 .../find_in_memory/address_ranges_helper.py   | 50 ---
 3 files changed, 45 insertions(+), 31 deletions(-)

diff --git a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py 
b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py
index 9ab4619b1f8f4f..04e807c5c6201d 100644
--- a/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py
+++ b/lldb/test/API/python_api/find_in_memory/TestFindInMemory.py
@@ -55,7 +55,7 @@ def test_find_in_memory_ok(self):
 error = lldb.SBError()
 addr = self.process.FindInMemory(
 SINGLE_INSTANCE_PATTERN_STACK,
-GetStackRange(self),
+GetStackRange(self, True),
 1,
 error,
 )
@@ -70,7 +70,7 @@ def test_find_in_memory_double_instance_ok(self):
 error = lldb.SBError()
 addr = self.process.FindInMemory(
 DOUBLE_INSTANCE_PATTERN_HEAP,
-GetHeapRanges(self)[0],
+GetHeapRanges(self, True)[0],
 1,
 error,
 )
@@ -86,7 +86,7 @@ def test_find_in_memory_invalid_alignment(self):
 error = lldb.SBError()
 addr = self.process.FindInMemory(
 SINGLE_INSTANCE_PATTERN_STACK,
-GetStackRange(self),
+GetStackRange(self, True),
 0,
 error,
 )
@@ -118,7 +118,7 @@ def test_find_in_memory_invalid_buffer(self):
 error = lldb.SBError()
 addr = self.process.FindInMemory(
 "",
-GetStackRange(self),
+GetStackRange(self, True),
 1,
 error,
 )
@@ -131,7 +131,7 @@ def test_find_in_memory_unaligned(self):
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertState(self.process.GetState(), lldb.eStateStopped, 
PROCESS_STOPPED)
 error = lldb.SBError()
-range = GetAlignedRange(self)
+range = GetAlignedRange(self, True)
 
 # First we make sure the pattern is found with alignment 1
 addr = self.process.FindInMemory(
diff --git a/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py 
b/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py
index 31bc0e99f4914f..895c527430f218 100644
--- a/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py
+++ b/lldb/test/API/python_api/find_in_memory/TestFindRangesInMemory.py
@@ -30,7 +30,7 @@ def test_find_ranges_in_memory_two_matches(self):
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertState(self.process.GetState(), lldb.eStateStopped, 
PROCESS_STOPPED)
 
-addr_ranges = GetHeapRanges(self)
+addr_ranges = GetHeapRanges(self, True)
 error = lldb.SBError()
 matches = self.process.FindRangesInMemory(
 DOUBLE_INSTANCE_PATTERN_HEAP,
@@ -48,7 +48,7 @@ def test_find_ranges_in_memory_one_match(self):
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertState(self.process.GetState(), lldb.eStateStopped, 
PROCESS_STOPPED)
 
-addr_ranges = GetStackRanges(self)
+addr_ranges = GetStackRanges(self, True)
 error = lldb.SBError()
 matches = self.process.FindRangesInMemory(
 SINGLE_INSTANCE_PATTERN_STACK,
@@ -66,7 +66,7 @@ def 
test_find_ranges_in_memory_one_match_multiple_ranges(self):
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertState(self.process.GetState(), lldb.eStateStopped, 
PROCESS_STOPPED)
 
-addr_ranges = GetRanges(self)
+addr_ranges = GetRanges(self, True)
 addr_ranges.Append(lldb.SBAddressRange())
 self.assertGreater(addr_ranges.GetSize(), 2)
 error = lldb.SBError()
@@ -86,7 +86,7 @@ def test_find_ranges_in_memory_one_match_max(self):
 self.assertTrue(self.process, PROCESS_IS_VALID)
 self.assertState(self.process.GetState(), lldb.eStateStopped, 
PROCESS_STOPPED)
 
-addr_ranges = GetHeapRanges(self)
+addr_ranges = GetHeapRanges(self, True)
 error = lldb.SBError()
 matches = self.process.Fi

[Lldb-commits] [lldb] [lldb][AIX] Added XCOFF Object File Header for AIX (PR #111814)

2024-10-10 Thread Dhruv Srivastava via lldb-commits

https://github.com/DhruvSrivastavaX created 
https://github.com/llvm/llvm-project/pull/111814

This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:
1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
2. #101657
The complete changes for porting are present in this draft PR:
#102601

Added XCOFF Object File Header for AIX.

Commit 1: Taken Linux version for reference.
Commit 2: Modified the class and header for AIX.
Details about XCOFF file format on AIX: 
[XCOFF](https://www.ibm.com/docs/en/aix/7.3?topic=formats-xcoff-object-file-format)

Review Request: @DavidSpickett

>From 08c9d5ae66ca857d165dc878ebd1b2e0de364a24 Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava 
Date: Thu, 10 Oct 2024 02:24:42 -0500
Subject: [PATCH 1/3] Taking base file structure from ELF as reference

---
 .../ObjectFile/XCOFF/ObjectFileXCOFF.h| 440 ++
 1 file changed, 440 insertions(+)
 create mode 100644 lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h

diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h 
b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
new file mode 100644
index 00..aba3a5bfcbf5b6
--- /dev/null
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
@@ -0,0 +1,440 @@
+//===-- ObjectFileELF.h --- -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_ELF_OBJECTFILEELF_H
+#define LLDB_SOURCE_PLUGINS_OBJECTFILE_ELF_OBJECTFILEELF_H
+
+#include 
+
+#include 
+#include 
+
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
+#include "lldb/lldb-private.h"
+
+#include "ELFHeader.h"
+
+struct ELFNote {
+  elf::elf_word n_namesz = 0;
+  elf::elf_word n_descsz = 0;
+  elf::elf_word n_type = 0;
+
+  std::string n_name;
+
+  ELFNote() = default;
+
+  /// Parse an ELFNote entry from the given DataExtractor starting at position
+  /// \p offset.
+  ///
+  /// \param[in] data
+  ///The DataExtractor to read from.
+  ///
+  /// \param[in,out] offset
+  ///Pointer to an offset in the data.  On return the offset will be
+  ///advanced by the number of bytes read.
+  ///
+  /// \return
+  ///True if the ELFRel entry was successfully read and false otherwise.
+  bool Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset);
+
+  size_t GetByteSize() const {
+return 12 + llvm::alignTo(n_namesz, 4) + llvm::alignTo(n_descsz, 4);
+  }
+};
+
+/// \class ObjectFileELF
+/// Generic ELF object file reader.
+///
+/// This class provides a generic ELF (32/64 bit) reader plugin implementing
+/// the ObjectFile protocol.
+class ObjectFileELF : public lldb_private::ObjectFile {
+public:
+  // Static Functions
+  static void Initialize();
+
+  static void Terminate();
+
+  static llvm::StringRef GetPluginNameStatic() { return "elf"; }
+
+  static llvm::StringRef GetPluginDescriptionStatic() {
+return "ELF object file reader.";
+  }
+
+  static lldb_private::ObjectFile *
+  CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
+ lldb::offset_t data_offset, const lldb_private::FileSpec 
*file,
+ lldb::offset_t file_offset, lldb::offset_t length);
+
+  static lldb_private::ObjectFile *CreateMemoryInstance(
+  const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp,
+  const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
+
+  static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
+lldb::DataBufferSP &data_sp,
+lldb::offset_t data_offset,
+lldb::offset_t file_offset,
+lldb::offset_t length,
+lldb_private::ModuleSpecList &specs);
+
+  static bool MagicBytesMatch(lldb::DataBufferSP &data_sp, lldb::addr_t offset,
+  lldb::addr_t length);
+
+  // PluginInterface protocol
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
+
+  // LLVM RTTI support
+  static char ID;
+  bool isA(const void *ClassID) const override {
+return ClassID == &ID || ObjectFile::isA(ClassID);
+  }
+  static bool classof(const ObjectFile *obj) { return obj->isA(&ID); }
+
+  // ObjectFile Protocol.
+  bool ParseHeader() override;
+
+  bool SetLoadAddress(lldb_private::Target &target, lldb::addr_t value,
+  bool value_is_offset) override;
+
+  lldb::ByteOrder GetByteOrder() const override;
+
+  bool IsExecutable() const override;
+
+  uint32

[Lldb-commits] [lldb] [lldb][AIX] Added XCOFF Object File Header for AIX (PR #111814)

2024-10-10 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dhruv Srivastava (DhruvSrivastavaX)


Changes

This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:
1. https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
2. #101657
The complete changes for porting are present in this draft PR:
#102601

Added XCOFF Object File Header for AIX.

Commit 1: Taken Linux version for reference.
Commit 2: Modified the class and header for AIX.
Details about XCOFF file format on AIX: 
[XCOFF](https://www.ibm.com/docs/en/aix/7.3?topic=formats-xcoff-object-file-format)

Review Request: @DavidSpickett

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


1 Files Affected:

- (added) lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h (+244) 


``diff
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h 
b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
new file mode 100644
index 00..2cb73394a0306d
--- /dev/null
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.h
@@ -0,0 +1,244 @@
+//===-- ObjectFileXCOFF.h --- -*- C++
+//-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_XCOFF_OBJECTFILEXCOFF_H
+#define LLDB_SOURCE_PLUGINS_OBJECTFILE_XCOFF_OBJECTFILEXCOFF_H
+
+#include 
+
+#include 
+
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/FileSpec.h"
+#include "lldb/Utility/UUID.h"
+#include "lldb/lldb-private.h"
+#include "llvm/Object/XCOFFObjectFile.h"
+
+/// \class ObjectFileXCOFF
+/// Generic XCOFF object file reader.
+///
+/// This class provides a generic XCOFF (32/64 bit) reader plugin implementing
+/// the ObjectFile protocol.
+class ObjectFileXCOFF : public lldb_private::ObjectFile {
+public:
+  // Static Functions
+  static void Initialize();
+
+  static void Terminate();
+
+  static llvm::StringRef GetPluginNameStatic() { return "xcoff"; }
+
+  static llvm::StringRef GetPluginDescriptionStatic() {
+return "XCOFF object file reader.";
+  }
+
+  static lldb_private::ObjectFile *
+  CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
+ lldb::offset_t data_offset, const lldb_private::FileSpec 
*file,
+ lldb::offset_t file_offset, lldb::offset_t length);
+
+  static lldb_private::ObjectFile *CreateMemoryInstance(
+  const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp,
+  const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
+
+  static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
+lldb::DataBufferSP &data_sp,
+lldb::offset_t data_offset,
+lldb::offset_t file_offset,
+lldb::offset_t length,
+lldb_private::ModuleSpecList &specs);
+
+  static bool MagicBytesMatch(lldb::DataBufferSP &data_sp, lldb::addr_t offset,
+  lldb::addr_t length);
+
+  static lldb::SymbolType MapSymbolType(llvm::object::SymbolRef::Type 
sym_type);
+
+  // PluginInterface protocol
+  llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
+
+  // LLVM RTTI support
+  static char ID;
+  bool isA(const void *ClassID) const override {
+return ClassID == &ID || ObjectFile::isA(ClassID);
+  }
+  static bool classof(const ObjectFile *obj) { return obj->isA(&ID); }
+
+  // ObjectFile Protocol.
+  bool ParseHeader() override;
+
+  bool SetLoadAddress(lldb_private::Target &target, lldb::addr_t value,
+  bool value_is_offset) override;
+
+  bool SetLoadAddressByType(lldb_private::Target &target, lldb::addr_t value,
+bool value_is_offset, int type_id) override;
+
+  lldb::ByteOrder GetByteOrder() const override;
+
+  bool IsExecutable() const override;
+
+  uint32_t GetAddressByteSize() const override;
+
+  lldb_private::AddressClass GetAddressClass(lldb::addr_t file_addr) override;
+
+  void ParseSymtab(lldb_private::Symtab &symtab) override;
+
+  bool IsStripped() override;
+
+  void CreateSections(lldb_private::SectionList &unified_section_list) 
override;
+
+  void Dump(lldb_private::Stream *s) override;
+
+  lldb_private::ArchSpec GetArchitecture() override;
+
+  lldb_private::UUID GetUUID() override;
+
+  /// Return the contents of the .gnu_debuglink section, if the object file
+  /// contains it.
+  std::optional GetDebugLink();
+
+  uint32_t GetDependentModules(lldb_private::FileSpecList &files) override;
+
+  lldb_private::Address
+  GetImageInfoAddress(lldb_private:

[Lldb-commits] [lldb] [lldb][test] Use $(STRIP) instead of strip in API tests. (PR #111816)

2024-10-10 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Vladislav Dzhidzhoev (dzhidzhoev)


Changes

This makes tests more portable.
Environment variables for LLVM utils are passed to `make` on Darwin as well.

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


7 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/builders/builder.py (+23-23) 
- (modified) lldb/test/API/lang/objc/hidden-ivars/Makefile (+2-2) 
- (modified) lldb/test/API/lang/objc/objc-ivar-stripped/Makefile (+1-1) 
- (modified) lldb/test/API/lang/objc/objc-static-method-stripped/Makefile 
(+1-1) 
- (modified) lldb/test/API/macosx/add-dsym/Makefile (+1-1) 
- (modified) lldb/test/API/tools/lldb-dap/module/Makefile (+1-1) 
- (modified) lldb/test/API/tools/lldb-dap/terminated-event/Makefile (+1-1) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index f813d68e46e82a..d399a5b228c131 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -169,31 +169,31 @@ def getToolchainUtil(util_name):
 if not os.getenv("LLVM_AR"):
 utils.extend(["LLVM_AR=%s" % getToolchainUtil("llvm-ar")])
 
-if not lldbplatformutil.platformIsDarwin():
-if cc_type in ["clang", "cc", "gcc"]:
-util_paths = {}
-# Assembly a toolchain side tool cmd based on passed CC.
-for var, name in util_names.items():
-# Do not override explicity specified tool from the cmd 
line.
-if not os.getenv(var):
-util_paths[var] = getToolchainUtil("llvm-" + name)
-else:
-util_paths[var] = os.getenv(var)
-utils.extend(["AR=%s" % util_paths["ARCHIVER"]])
-
-# Look for llvm-dwp or gnu dwp
-if not lldbutil.which(util_paths["DWP"]):
-util_paths["DWP"] = getToolchainUtil("llvm-dwp")
-if not lldbutil.which(util_paths["DWP"]):
-util_paths["DWP"] = lldbutil.which("llvm-dwp")
+if cc_type in ["clang", "cc", "gcc"]:
+util_paths = {}
+# Assembly a toolchain side tool cmd based on passed CC.
+for var, name in util_names.items():
+# Do not override explicity specified tool from the cmd line.
+if not os.getenv(var):
+util_paths[var] = getToolchainUtil("llvm-" + name)
+else:
+util_paths[var] = os.getenv(var)
+utils.extend(["AR=%s" % util_paths["ARCHIVER"]])
+
+# Look for llvm-dwp or gnu dwp
+if not lldbutil.which(util_paths["DWP"]):
+util_paths["DWP"] = getToolchainUtil("llvm-dwp")
+if not lldbutil.which(util_paths["DWP"]):
+util_paths["DWP"] = lldbutil.which("llvm-dwp")
+if not util_paths["DWP"]:
+util_paths["DWP"] = lldbutil.which("dwp")
 if not util_paths["DWP"]:
-util_paths["DWP"] = lldbutil.which("dwp")
-if not util_paths["DWP"]:
-del util_paths["DWP"]
+del util_paths["DWP"]
 
-for var, path in util_paths.items():
-utils.append("%s=%s" % (var, path))
-else:
+for var, path in util_paths.items():
+utils.append("%s=%s" % (var, path))
+
+if lldbplatformutil.platformIsDarwin():
 utils.extend(["AR=%slibtool" % os.getenv("CROSS_COMPILE", "")])
 
 return [
diff --git a/lldb/test/API/lang/objc/hidden-ivars/Makefile 
b/lldb/test/API/lang/objc/hidden-ivars/Makefile
index 283e8a118fb16a..c94c0dee1b9ce9 100644
--- a/lldb/test/API/lang/objc/hidden-ivars/Makefile
+++ b/lldb/test/API/lang/objc/hidden-ivars/Makefile
@@ -14,8 +14,8 @@ endif
 
 stripped: a.out libInternalDefiner.dylib
mkdir stripped
-   strip -Sx a.out -o stripped/a.out
-   strip -Sx libInternalDefiner.dylib -o stripped/libInternalDefiner.dylib
+   $(STRIP) -Sx a.out -o stripped/a.out
+   $(STRIP) -Sx libInternalDefiner.dylib -o 
stripped/libInternalDefiner.dylib
 ifneq "$(CODESIGN)" ""
$(CODESIGN) -fs - stripped/a.out
 endif
diff --git a/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile 
b/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile
index 8b63215d6d9da6..eed66d2a965d11 100644
--- a/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile
+++ b/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile
@@ -6,7 +6,7 @@ all:a.out.stripped
 include Makefile.rules
 
 a.out.stripped: a.out.dSYM
-   strip -o a.out.stripped a.out
+   $(STRIP) -o a.out.stripped a.out
 ifneq "$(CODESIGN)" ""
$(CODESIGN) -fs - a.out.stripped
 endif
diff --git a/lldb/test/API/lang/objc/objc-static-method-str

[Lldb-commits] [lldb] [lldb][AIX] Added XCOFF Object File Header for AIX (PR #111814)

2024-10-10 Thread Dhruv Srivastava via lldb-commits

DhruvSrivastavaX wrote:

Hi Community Members, 

Apologies for being away for a while as I was occupied with some other 
activities. 
Here's some update at what all we are working on based on the past discussions:

1. Removed the CMAKE flag __AIX__ and replaced it with the LLVM environment's 
_AIX flag [**Done**]

2. We are working on merging some of the common files (like HostInfoAIX.cpp 
etc) derived from Linux while avoiding any major impact.
3. Working on creating a draft PR as suggested by @DavidSpickett , to highlight 
all the #if (_AIX) kind of code in the draft PR, to see the overall impact. 
4. Implementing additional functionalities which are currently missing on AIX.
5. Rearranging some of the code in the draft PR based on the previous 
discussions. 

Going forward @Lakshmi-Surekha will also be assisting me in some of the 
upstreaming activities. 

Thanks & Regards




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


[Lldb-commits] [lldb] [lldb][test] Use $(STRIP) instead of strip in API tests (PR #111816)

2024-10-10 Thread Vladislav Dzhidzhoev via lldb-commits

https://github.com/dzhidzhoev edited 
https://github.com/llvm/llvm-project/pull/111816
___
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 XCOFF Object File Header for AIX (PR #111814)

2024-10-10 Thread Dhruv Srivastava via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Use $(STRIP) instead of strip in API tests (Darwin-only change) (PR #111816)

2024-10-10 Thread Michael Buch via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][test] Use $(STRIP) instead of strip in API tests. (PR #111816)

2024-10-10 Thread Vladislav Dzhidzhoev via lldb-commits

https://github.com/dzhidzhoev created 
https://github.com/llvm/llvm-project/pull/111816

This makes tests more portable.
Environment variables for LLVM utils are passed to `make` on Darwin as well.

>From 050b000a5fe4fd517fefed1532e6cf56e2bb147b Mon Sep 17 00:00:00 2001
From: Vladimir Vereschaka 
Date: Thu, 9 May 2024 03:22:15 +
Subject: [PATCH] [lldb][test] Use $(STRIP) instead of strip in API tests.

This allows to make tests more portable.
Environment variables for LLVM utils are passed to `make` on Darwin as
well.
---
 .../Python/lldbsuite/test/builders/builder.py | 46 +--
 lldb/test/API/lang/objc/hidden-ivars/Makefile |  4 +-
 .../API/lang/objc/objc-ivar-stripped/Makefile |  2 +-
 .../objc/objc-static-method-stripped/Makefile |  2 +-
 lldb/test/API/macosx/add-dsym/Makefile|  2 +-
 lldb/test/API/tools/lldb-dap/module/Makefile  |  2 +-
 .../tools/lldb-dap/terminated-event/Makefile  |  2 +-
 7 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index f813d68e46e82a..d399a5b228c131 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -169,31 +169,31 @@ def getToolchainUtil(util_name):
 if not os.getenv("LLVM_AR"):
 utils.extend(["LLVM_AR=%s" % getToolchainUtil("llvm-ar")])
 
-if not lldbplatformutil.platformIsDarwin():
-if cc_type in ["clang", "cc", "gcc"]:
-util_paths = {}
-# Assembly a toolchain side tool cmd based on passed CC.
-for var, name in util_names.items():
-# Do not override explicity specified tool from the cmd 
line.
-if not os.getenv(var):
-util_paths[var] = getToolchainUtil("llvm-" + name)
-else:
-util_paths[var] = os.getenv(var)
-utils.extend(["AR=%s" % util_paths["ARCHIVER"]])
-
-# Look for llvm-dwp or gnu dwp
-if not lldbutil.which(util_paths["DWP"]):
-util_paths["DWP"] = getToolchainUtil("llvm-dwp")
-if not lldbutil.which(util_paths["DWP"]):
-util_paths["DWP"] = lldbutil.which("llvm-dwp")
+if cc_type in ["clang", "cc", "gcc"]:
+util_paths = {}
+# Assembly a toolchain side tool cmd based on passed CC.
+for var, name in util_names.items():
+# Do not override explicity specified tool from the cmd line.
+if not os.getenv(var):
+util_paths[var] = getToolchainUtil("llvm-" + name)
+else:
+util_paths[var] = os.getenv(var)
+utils.extend(["AR=%s" % util_paths["ARCHIVER"]])
+
+# Look for llvm-dwp or gnu dwp
+if not lldbutil.which(util_paths["DWP"]):
+util_paths["DWP"] = getToolchainUtil("llvm-dwp")
+if not lldbutil.which(util_paths["DWP"]):
+util_paths["DWP"] = lldbutil.which("llvm-dwp")
+if not util_paths["DWP"]:
+util_paths["DWP"] = lldbutil.which("dwp")
 if not util_paths["DWP"]:
-util_paths["DWP"] = lldbutil.which("dwp")
-if not util_paths["DWP"]:
-del util_paths["DWP"]
+del util_paths["DWP"]
 
-for var, path in util_paths.items():
-utils.append("%s=%s" % (var, path))
-else:
+for var, path in util_paths.items():
+utils.append("%s=%s" % (var, path))
+
+if lldbplatformutil.platformIsDarwin():
 utils.extend(["AR=%slibtool" % os.getenv("CROSS_COMPILE", "")])
 
 return [
diff --git a/lldb/test/API/lang/objc/hidden-ivars/Makefile 
b/lldb/test/API/lang/objc/hidden-ivars/Makefile
index 283e8a118fb16a..c94c0dee1b9ce9 100644
--- a/lldb/test/API/lang/objc/hidden-ivars/Makefile
+++ b/lldb/test/API/lang/objc/hidden-ivars/Makefile
@@ -14,8 +14,8 @@ endif
 
 stripped: a.out libInternalDefiner.dylib
mkdir stripped
-   strip -Sx a.out -o stripped/a.out
-   strip -Sx libInternalDefiner.dylib -o stripped/libInternalDefiner.dylib
+   $(STRIP) -Sx a.out -o stripped/a.out
+   $(STRIP) -Sx libInternalDefiner.dylib -o 
stripped/libInternalDefiner.dylib
 ifneq "$(CODESIGN)" ""
$(CODESIGN) -fs - stripped/a.out
 endif
diff --git a/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile 
b/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile
index 8b63215d6d9da6..eed66d2a965d11 100644
--- a/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile
+++ b/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile
@@ -6,7 +6,7 @@ all:a.out.stripped
 include Makefile.rules
 
 a.out.stripped: a.out.dSYM
-   strip -o a.out.stripped a.out
+

[Lldb-commits] [lldb] [lldb][AIX] Added XCOFF Object File Header for AIX (PR #111814)

2024-10-10 Thread Pavel Labath via lldb-commits

labath wrote:

A couple of quick notes:
- are you sure that ObjectFileELF is the best thing to start with here? Based 
on the name, I would expect that ObjectFilePECOFF would be a better baseline. 
Or maybe the object file format is different enough from all of the existing 
ones that this kind of comparison is not useful?
- without also seeing the cpp file, it hard to judge how similar it is to the 
other plugin
- instead of redeclaring all the header types, would it be possible to use some 
structures from llvm? (I know that ObjectFileELF does not do that, but that's 
because it is very old. ObjectFilePECOFF -- a much newer class -- does just 
that)
- a lot of the object file code should be testable on its own. If you include 
the necessary plugin glue in this PR, then you should be able to write tests 
similar to those in `lldb/test/Shell/ObjectFile`. For example, if you could 
start with a test similar to `test/Shell/ObjectFile/ELF/basic-info.yaml` and 
then include enough of code in the PR to make that pass.

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


[Lldb-commits] [lldb] [lldb][test] Use $(STRIP) instead of strip in API tests (PR #111816)

2024-10-10 Thread Michael Buch via lldb-commits

Michael137 wrote:

could you mention that this is a`Darwin`-only change in the commit/PR title?

Otherwise, LGTM. Will help with the situation i ran into a while ago: 
https://reviews.llvm.org/D143842

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


[Lldb-commits] [lldb] [lldb][test] Use llvm-strip instead of strip on non-Darwin platforms for TestSymbolFileJSON (PR #111820)

2024-10-10 Thread Vladislav Dzhidzhoev via lldb-commits

https://github.com/dzhidzhoev created 
https://github.com/llvm/llvm-project/pull/111820

This is to fix buildbot failure 
https://lab.llvm.org/staging/#/builders/195/builds/4242.

The test can't be used with llvm-strip on macOS. Apparently, 
llvm-strip/llvm-objcopy can't clean symbols from Mach-O nlists.

>From 3f7155ed55d0b34bd8633a0a2d1303fd8757f0f4 Mon Sep 17 00:00:00 2001
From: Vladislav Dzhidzhoev 
Date: Thu, 10 Oct 2024 13:54:55 +0200
Subject: [PATCH] [lldb][test] Use llvm-strip instead of strip on non-Darwin
 platforms for TestSymbolFileJSON

This is to fix buildbot failure
https://lab.llvm.org/staging/#/builders/195/builds/4242.

The test can't be used with llvm-strip on macOS. Apparently,
llvm-strip/llvm-objcopy can't clean symbols from mach-O nlists.
---
 lldb/test/API/functionalities/json/symbol-file/Makefile | 4 
 1 file changed, 4 insertions(+)

diff --git a/lldb/test/API/functionalities/json/symbol-file/Makefile 
b/lldb/test/API/functionalities/json/symbol-file/Makefile
index aff841c364299c..1df4a16fbf4d91 100644
--- a/lldb/test/API/functionalities/json/symbol-file/Makefile
+++ b/lldb/test/API/functionalities/json/symbol-file/Makefile
@@ -3,6 +3,10 @@ C_SOURCES := main.c
 all: stripped.out
 
 stripped.out : a.out
+ifeq "$(OS)" "Darwin"
strip a.out -o stripped.out
+else
+   $(STRIP) a.out -o stripped.out
+endif
 
 include Makefile.rules

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


[Lldb-commits] [lldb] [lldb][test] Use $(STRIP) instead of strip in API tests (PR #111816)

2024-10-10 Thread Vladislav Dzhidzhoev via lldb-commits

dzhidzhoev wrote:

> > Environment variables for LLVM utils are passed to make on Darwin as well.
> 
> Technically, these are `make` variables, right?

Yes. I'll fix it in the description.

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


[Lldb-commits] [lldb] [lldb][test] Use $(STRIP) instead of strip in API tests (PR #111816)

2024-10-10 Thread Vladislav Dzhidzhoev via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Use llvm-strip instead of strip on non-Darwin platforms for TestSymbolFileJSON (PR #111820)

2024-10-10 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Vladislav Dzhidzhoev (dzhidzhoev)


Changes

This is to fix buildbot failure 
https://lab.llvm.org/staging/#/builders/195/builds/4242.

The test can't be used with llvm-strip on macOS. Apparently, 
llvm-strip/llvm-objcopy can't clean symbols from Mach-O nlists.

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


1 Files Affected:

- (modified) lldb/test/API/functionalities/json/symbol-file/Makefile (+4) 


``diff
diff --git a/lldb/test/API/functionalities/json/symbol-file/Makefile 
b/lldb/test/API/functionalities/json/symbol-file/Makefile
index aff841c364299c..1df4a16fbf4d91 100644
--- a/lldb/test/API/functionalities/json/symbol-file/Makefile
+++ b/lldb/test/API/functionalities/json/symbol-file/Makefile
@@ -3,6 +3,10 @@ C_SOURCES := main.c
 all: stripped.out
 
 stripped.out : a.out
+ifeq "$(OS)" "Darwin"
strip a.out -o stripped.out
+else
+   $(STRIP) a.out -o stripped.out
+endif
 
 include Makefile.rules

``




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


[Lldb-commits] [lldb] [lldb][test] Use $(STRIP) instead of strip in API tests (Darwin-only change) (PR #111816)

2024-10-10 Thread Vladislav Dzhidzhoev via lldb-commits

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


[Lldb-commits] [lldb] b773da0 - [lldb][test] Use $(STRIP) instead of strip in API tests (Darwin-only change) (#111816)

2024-10-10 Thread via lldb-commits

Author: Vladislav Dzhidzhoev
Date: 2024-10-10T14:21:25+02:00
New Revision: b773da0c5eed06f21f4caeea5eae47cacefb376c

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

LOG: [lldb][test] Use $(STRIP) instead of strip in API tests (Darwin-only 
change) (#111816)

This makes tests more portable.
Make variables for LLVM utils are passed to `make` on Darwin as well.

Co-authored-by: Vladimir Vereschaka 

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/builders/builder.py
lldb/test/API/lang/objc/hidden-ivars/Makefile
lldb/test/API/lang/objc/objc-ivar-stripped/Makefile
lldb/test/API/lang/objc/objc-static-method-stripped/Makefile
lldb/test/API/macosx/add-dsym/Makefile
lldb/test/API/tools/lldb-dap/module/Makefile
lldb/test/API/tools/lldb-dap/terminated-event/Makefile

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py 
b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index f813d68e46e82a..d399a5b228c131 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -169,31 +169,31 @@ def getToolchainUtil(util_name):
 if not os.getenv("LLVM_AR"):
 utils.extend(["LLVM_AR=%s" % getToolchainUtil("llvm-ar")])
 
-if not lldbplatformutil.platformIsDarwin():
-if cc_type in ["clang", "cc", "gcc"]:
-util_paths = {}
-# Assembly a toolchain side tool cmd based on passed CC.
-for var, name in util_names.items():
-# Do not override explicity specified tool from the cmd 
line.
-if not os.getenv(var):
-util_paths[var] = getToolchainUtil("llvm-" + name)
-else:
-util_paths[var] = os.getenv(var)
-utils.extend(["AR=%s" % util_paths["ARCHIVER"]])
-
-# Look for llvm-dwp or gnu dwp
-if not lldbutil.which(util_paths["DWP"]):
-util_paths["DWP"] = getToolchainUtil("llvm-dwp")
-if not lldbutil.which(util_paths["DWP"]):
-util_paths["DWP"] = lldbutil.which("llvm-dwp")
+if cc_type in ["clang", "cc", "gcc"]:
+util_paths = {}
+# Assembly a toolchain side tool cmd based on passed CC.
+for var, name in util_names.items():
+# Do not override explicity specified tool from the cmd line.
+if not os.getenv(var):
+util_paths[var] = getToolchainUtil("llvm-" + name)
+else:
+util_paths[var] = os.getenv(var)
+utils.extend(["AR=%s" % util_paths["ARCHIVER"]])
+
+# Look for llvm-dwp or gnu dwp
+if not lldbutil.which(util_paths["DWP"]):
+util_paths["DWP"] = getToolchainUtil("llvm-dwp")
+if not lldbutil.which(util_paths["DWP"]):
+util_paths["DWP"] = lldbutil.which("llvm-dwp")
+if not util_paths["DWP"]:
+util_paths["DWP"] = lldbutil.which("dwp")
 if not util_paths["DWP"]:
-util_paths["DWP"] = lldbutil.which("dwp")
-if not util_paths["DWP"]:
-del util_paths["DWP"]
+del util_paths["DWP"]
 
-for var, path in util_paths.items():
-utils.append("%s=%s" % (var, path))
-else:
+for var, path in util_paths.items():
+utils.append("%s=%s" % (var, path))
+
+if lldbplatformutil.platformIsDarwin():
 utils.extend(["AR=%slibtool" % os.getenv("CROSS_COMPILE", "")])
 
 return [

diff  --git a/lldb/test/API/lang/objc/hidden-ivars/Makefile 
b/lldb/test/API/lang/objc/hidden-ivars/Makefile
index 283e8a118fb16a..c94c0dee1b9ce9 100644
--- a/lldb/test/API/lang/objc/hidden-ivars/Makefile
+++ b/lldb/test/API/lang/objc/hidden-ivars/Makefile
@@ -14,8 +14,8 @@ endif
 
 stripped: a.out libInternalDefiner.dylib
mkdir stripped
-   strip -Sx a.out -o stripped/a.out
-   strip -Sx libInternalDefiner.dylib -o stripped/libInternalDefiner.dylib
+   $(STRIP) -Sx a.out -o stripped/a.out
+   $(STRIP) -Sx libInternalDefiner.dylib -o 
stripped/libInternalDefiner.dylib
 ifneq "$(CODESIGN)" ""
$(CODESIGN) -fs - stripped/a.out
 endif

diff  --git a/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile 
b/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile
index 8b63215d6d9da6..eed66d2a965d11 100644
--- a/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile
+++ b/lldb/test/API/lang/objc/objc-ivar-stripped/Makefile
@@ -6,7 +6,7 @@ all:a.out.stripped
 include Makefile.rules
 
 a.out

[Lldb-commits] [lldb] 993de55 - [lldb][docs] Add link to RISC-V tracking issue in Platform Support

2024-10-10 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2024-10-10T10:21:41+01:00
New Revision: 993de5512d81f4582373aa8bd7507e5aa44311ab

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

LOG: [lldb][docs] Add link to RISC-V tracking issue in Platform Support

Saves me searching for this every time someone asks.

Added: 


Modified: 
lldb/docs/index.rst

Removed: 




diff  --git a/lldb/docs/index.rst b/lldb/docs/index.rst
index dd44a8430add80..2c7d7dbfad9a50 100644
--- a/lldb/docs/index.rst
+++ b/lldb/docs/index.rst
@@ -81,6 +81,10 @@ are welcome:
 expected to work, with functionality improving rapidly. ARM and AArch64 support
 is more experimental, with more known issues than the others.
 
+RISC-V support is in active development, refer to the
+`tracking issue `_
+for the current status.
+
 Get Involved
 
 



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


[Lldb-commits] [lldb] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)

2024-10-10 Thread David Spickett via lldb-commits


@@ -492,23 +492,36 @@ NativeProcessWindows::OnDebugException(bool first_chance,
   }
   case DWORD(STATUS_BREAKPOINT):
   case STATUS_WX86_BREAKPOINT:
-if (FindSoftwareBreakpoint(record.GetExceptionAddress())) {
-  LLDB_LOG(log, "Hit non-loader breakpoint at address {0:x}.",
-   record.GetExceptionAddress());
-
-  StopThread(record.GetThreadID(), StopReason::eStopReasonBreakpoint);
 
-  if (NativeThreadWindows *stop_thread =
-  GetThreadByID(record.GetThreadID())) {
-auto ®ister_context = stop_thread->GetRegisterContext();
-uint32_t breakpoint_size = GetSoftwareBreakpointPCOffset();
-// The current PC is AFTER the BP opcode, on all architectures.
-uint64_t pc = register_context.GetPC() - breakpoint_size;
-register_context.SetPC(pc);
+if (NativeThreadWindows *stop_thread =
+GetThreadByID(record.GetThreadID())) {
+  auto ®_ctx = stop_thread->GetRegisterContext();
+  const auto exception_addr = record.GetExceptionAddress();
+  const auto thread_id = record.GetThreadID();
+
+  if (FindSoftwareBreakpoint(exception_addr)) {
+LLDB_LOG(log, "Hit non-loader breakpoint at address {0:x}.",
+ exception_addr);
+
+reg_ctx.SetPC(reg_ctx.GetPC() - GetSoftwareBreakpointPCOffset());
+StopThread(thread_id, StopReason::eStopReasonBreakpoint);
+SetState(eStateStopped, true);
+return ExceptionResult::MaskException;
+  } else {
+const std::vector &args = record.GetExceptionArguments();
+if (args.size() >= 2) {

DavidSpickett wrote:

Worth adding a comment here to say what the two are, because it's clear that 
args[1] is an address but you ignore args[0] which is suspicious without 
context.

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


[Lldb-commits] [lldb] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)

2024-10-10 Thread David Spickett via lldb-commits


@@ -492,23 +492,36 @@ NativeProcessWindows::OnDebugException(bool first_chance,
   }
   case DWORD(STATUS_BREAKPOINT):
   case STATUS_WX86_BREAKPOINT:
-if (FindSoftwareBreakpoint(record.GetExceptionAddress())) {
-  LLDB_LOG(log, "Hit non-loader breakpoint at address {0:x}.",
-   record.GetExceptionAddress());
-
-  StopThread(record.GetThreadID(), StopReason::eStopReasonBreakpoint);
 
-  if (NativeThreadWindows *stop_thread =
-  GetThreadByID(record.GetThreadID())) {
-auto ®ister_context = stop_thread->GetRegisterContext();
-uint32_t breakpoint_size = GetSoftwareBreakpointPCOffset();
-// The current PC is AFTER the BP opcode, on all architectures.
-uint64_t pc = register_context.GetPC() - breakpoint_size;
-register_context.SetPC(pc);
+if (NativeThreadWindows *stop_thread =
+GetThreadByID(record.GetThreadID())) {
+  auto ®_ctx = stop_thread->GetRegisterContext();
+  const auto exception_addr = record.GetExceptionAddress();
+  const auto thread_id = record.GetThreadID();
+
+  if (FindSoftwareBreakpoint(exception_addr)) {
+LLDB_LOG(log, "Hit non-loader breakpoint at address {0:x}.",

DavidSpickett wrote:

What does loader mean in this context? Is it anything like the dynamic linker 
on Linux? If so I assume this means we hit a breakpoint that wasn't placed by 
the system, because if it was we should be ignoring it.

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


[Lldb-commits] [lldb] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)

2024-10-10 Thread David Spickett via lldb-commits


@@ -143,8 +142,14 @@ 
NativeRegisterContextWindows::CreateHostNativeRegisterContextWindows(
 
 NativeRegisterContextWindows_arm64::NativeRegisterContextWindows_arm64(
 const ArchSpec &target_arch, NativeThreadProtocol &native_thread)
-: NativeRegisterContextWindows(native_thread,
-   CreateRegisterInfoInterface(target_arch)) {}
+: NativeRegisterContextRegisterInfo(
+  native_thread, CreateRegisterInfoInterface(target_arch)) {
+  // Currently, there is no API to query the maximum supported hardware
+  // breakpoints and watchpoints on Windows. The values set below are based
+  // on tests conducted on Windows 11 with Snapdragon Elite X hardware.
+  m_max_hwp_supported = 1;

DavidSpickett wrote:

With only 1 useable, are there a lot of tests that don't work?

Which is fine if so, just curious. Enabling watchpoint tests overall doesn't 
have to be a goal of this PR, if it works at all it'll be an improvement.

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


[Lldb-commits] [lldb] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)

2024-10-10 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)

2024-10-10 Thread David Spickett via lldb-commits


@@ -143,8 +142,14 @@ 
NativeRegisterContextWindows::CreateHostNativeRegisterContextWindows(
 
 NativeRegisterContextWindows_arm64::NativeRegisterContextWindows_arm64(
 const ArchSpec &target_arch, NativeThreadProtocol &native_thread)
-: NativeRegisterContextWindows(native_thread,
-   CreateRegisterInfoInterface(target_arch)) {}
+: NativeRegisterContextRegisterInfo(
+  native_thread, CreateRegisterInfoInterface(target_arch)) {
+  // Currently, there is no API to query the maximum supported hardware
+  // breakpoints and watchpoints on Windows. The values set below are based
+  // on tests conducted on Windows 11 with Snapdragon Elite X hardware.
+  m_max_hwp_supported = 1;
+  m_max_hbp_supported = 0;

DavidSpickett wrote:

If this patch is only watchpoint support, this should be removed.

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


[Lldb-commits] [lldb] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)

2024-10-10 Thread David Spickett via lldb-commits


@@ -492,23 +492,36 @@ NativeProcessWindows::OnDebugException(bool first_chance,
   }
   case DWORD(STATUS_BREAKPOINT):
   case STATUS_WX86_BREAKPOINT:
-if (FindSoftwareBreakpoint(record.GetExceptionAddress())) {
-  LLDB_LOG(log, "Hit non-loader breakpoint at address {0:x}.",
-   record.GetExceptionAddress());
-
-  StopThread(record.GetThreadID(), StopReason::eStopReasonBreakpoint);
 
-  if (NativeThreadWindows *stop_thread =
-  GetThreadByID(record.GetThreadID())) {
-auto ®ister_context = stop_thread->GetRegisterContext();
-uint32_t breakpoint_size = GetSoftwareBreakpointPCOffset();
-// The current PC is AFTER the BP opcode, on all architectures.
-uint64_t pc = register_context.GetPC() - breakpoint_size;
-register_context.SetPC(pc);
+if (NativeThreadWindows *stop_thread =
+GetThreadByID(record.GetThreadID())) {
+  auto ®_ctx = stop_thread->GetRegisterContext();
+  const auto exception_addr = record.GetExceptionAddress();
+  const auto thread_id = record.GetThreadID();
+
+  if (FindSoftwareBreakpoint(exception_addr)) {
+LLDB_LOG(log, "Hit non-loader breakpoint at address {0:x}.",
+ exception_addr);
+
+reg_ctx.SetPC(reg_ctx.GetPC() - GetSoftwareBreakpointPCOffset());

DavidSpickett wrote:

Does the call to GetSoftwareBreakpointPCOffset replace the comment:
```
// The current PC is AFTER the BP opcode, on all architectures.
```
Want to make sure we don't lose this detail, but if 
GetSoftwareBreakpointPCOffset handles it then this is fine.

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


[Lldb-commits] [lldb] [lldb][Windows] WoA HW Watchpoint support in LLDB (PR #108072)

2024-10-10 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett commented:

So is this X86 and ARM64 or just one?

Also this needs a release note, which is a good place to note the limitations 
as well.

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


[Lldb-commits] [lldb] [LLDB][Minidump] Have Minidumps save off and properly read TLS data (PR #109477)

2024-10-10 Thread Pavel Labath via lldb-commits


@@ -337,6 +338,17 @@ class DynamicLoader : public PluginInterface {
 return std::nullopt;
   }
 
+  /// Returns a list of memory ranges that should be saved in the core file,
+  /// specific for this dßynamic loader.

labath wrote:

```suggestion
  /// specific for this dynamic loader.
```

:de: 

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


[Lldb-commits] [lldb] [LLDB][Minidump] Have Minidumps save off and properly read TLS data (PR #109477)

2024-10-10 Thread Pavel Labath via lldb-commits


@@ -337,6 +338,17 @@ class DynamicLoader : public PluginInterface {
 return std::nullopt;
   }
 
+  /// Returns a list of memory ranges that should be saved in the core file,
+  /// specific for this dßynamic loader.
+  ///
+  /// By default, this returns an empty list, but for POSIX/ELF it will return

labath wrote:

Let's not refer to specific subclasses here. It's an indication of bad layering 
and is bound to get out of date if anyone else implements this method. You 
could say "For example, an implementation can return the memory ranges 
necessary to locate thread local data (via GetThreadLocalData) in the saved 
core file."

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


[Lldb-commits] [lldb] [LLDB][Minidump] Have Minidumps save off and properly read TLS data (PR #109477)

2024-10-10 Thread Pavel Labath via lldb-commits


@@ -866,3 +867,81 @@ bool DynamicLoaderPOSIXDYLD::AlwaysRelyOnEHUnwindInfo(
 bool DynamicLoaderPOSIXDYLD::IsCoreFile() const {
   return !m_process->IsLiveDebugSession();
 }
+
+// For our ELF/POSIX builds save off the fs_base/gs_base regions
+static void AddSegmentRegisterSections(Process &process, ThreadSP &thread_sp,
+   std::vector &ranges) {
+  lldb::RegisterContextSP reg_ctx = thread_sp->GetRegisterContext();
+  if (!reg_ctx)
+return;
+
+  const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(
+  lldb::RegisterKind::eRegisterKindGeneric, LLDB_REGNUM_GENERIC_TP);
+  if (!reg_info)
+return;
+
+  lldb_private::RegisterValue thread_local_register_value;
+  bool success = reg_ctx->ReadRegister(reg_info, thread_local_register_value);
+  if (!success)
+return;
+
+  const uint64_t fail_value = UINT64_MAX;
+  bool readSuccess = false;
+  const lldb::addr_t reg_value_addr =
+  thread_local_register_value.GetAsUInt64(fail_value, &readSuccess);
+  if (!readSuccess || reg_value_addr == fail_value)
+return;
+
+  MemoryRegionInfo thread_local_region;
+  Status err = process.GetMemoryRegionInfo(reg_value_addr, 
thread_local_region);
+  if (err.Fail())
+return;
+
+  ranges.push_back(thread_local_region);
+}
+
+// Save off the link map for core files.
+static void AddLinkMapSections(Process &process,
+   std::vector &ranges) {
+  ModuleList &module_list = process.GetTarget().GetImages();
+  Target *target = &process.GetTarget();
+  for (size_t idx = 0; idx < module_list.GetSize(); idx++) {
+ModuleSP module_sp = module_list.GetModuleAtIndex(idx);
+if (!module_sp)
+  continue;
+
+ObjectFile *obj = module_sp->GetObjectFile();
+if (!obj)
+  continue;
+Address addr = obj->GetImageInfoAddress(target);
+addr_t load_addr = addr.GetLoadAddress(target);
+if (load_addr == LLDB_INVALID_ADDRESS)
+  continue;
+
+MemoryRegionInfo link_map_section;
+Status err = process.GetMemoryRegionInfo(load_addr, link_map_section);
+if (err.Fail())
+  continue;
+
+ranges.push_back(link_map_section);
+  }
+}
+
+void DynamicLoaderPOSIXDYLD::CalculateDynamicSaveCoreRanges(
+lldb_private::Process &process,
+std::vector &ranges,
+std::function save_thread_predicate) {

labath wrote:

```suggestion
llvm::function_ref 
save_thread_predicate) {
```

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


[Lldb-commits] [lldb] [LLDB][Minidump] Have Minidumps save off and properly read TLS data (PR #109477)

2024-10-10 Thread Pavel Labath via lldb-commits


@@ -866,3 +867,81 @@ bool DynamicLoaderPOSIXDYLD::AlwaysRelyOnEHUnwindInfo(
 bool DynamicLoaderPOSIXDYLD::IsCoreFile() const {
   return !m_process->IsLiveDebugSession();
 }
+
+// For our ELF/POSIX builds save off the fs_base/gs_base regions
+static void AddSegmentRegisterSections(Process &process, ThreadSP &thread_sp,
+   std::vector &ranges) {
+  lldb::RegisterContextSP reg_ctx = thread_sp->GetRegisterContext();
+  if (!reg_ctx)
+return;
+
+  const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(
+  lldb::RegisterKind::eRegisterKindGeneric, LLDB_REGNUM_GENERIC_TP);
+  if (!reg_info)
+return;
+
+  lldb_private::RegisterValue thread_local_register_value;
+  bool success = reg_ctx->ReadRegister(reg_info, thread_local_register_value);
+  if (!success)
+return;
+
+  const uint64_t fail_value = UINT64_MAX;
+  bool readSuccess = false;
+  const lldb::addr_t reg_value_addr =
+  thread_local_register_value.GetAsUInt64(fail_value, &readSuccess);
+  if (!readSuccess || reg_value_addr == fail_value)
+return;
+
+  MemoryRegionInfo thread_local_region;
+  Status err = process.GetMemoryRegionInfo(reg_value_addr, 
thread_local_region);
+  if (err.Fail())
+return;
+
+  ranges.push_back(thread_local_region);
+}
+
+// Save off the link map for core files.
+static void AddLinkMapSections(Process &process,
+   std::vector &ranges) {
+  ModuleList &module_list = process.GetTarget().GetImages();
+  Target *target = &process.GetTarget();
+  for (size_t idx = 0; idx < module_list.GetSize(); idx++) {
+ModuleSP module_sp = module_list.GetModuleAtIndex(idx);
+if (!module_sp)
+  continue;
+
+ObjectFile *obj = module_sp->GetObjectFile();
+if (!obj)
+  continue;
+Address addr = obj->GetImageInfoAddress(target);
+addr_t load_addr = addr.GetLoadAddress(target);
+if (load_addr == LLDB_INVALID_ADDRESS)
+  continue;
+
+MemoryRegionInfo link_map_section;
+Status err = process.GetMemoryRegionInfo(load_addr, link_map_section);
+if (err.Fail())
+  continue;
+
+ranges.push_back(link_map_section);
+  }
+}
+
+void DynamicLoaderPOSIXDYLD::CalculateDynamicSaveCoreRanges(
+lldb_private::Process &process,
+std::vector &ranges,
+std::function save_thread_predicate) {
+  ThreadList &thread_list = process.GetThreadList();
+  for (size_t idx = 0; idx < thread_list.GetSize(); idx++) {
+ThreadSP thread_sp = thread_list.GetThreadAtIndex(idx);
+if (!thread_sp)
+  continue;
+
+if (!save_thread_predicate(*thread_sp.get()))

labath wrote:

```suggestion
if (!save_thread_predicate(*thread_sp))
```

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


[Lldb-commits] [lldb] [LLDB][Minidump] Have Minidumps save off and properly read TLS data (PR #109477)

2024-10-10 Thread Pavel Labath via lldb-commits


@@ -6528,6 +6528,75 @@ static void AddRegion(const MemoryRegionInfo ®ion, 
bool try_dirty_pages,
 CreateCoreFileMemoryRange(region));
 }
 
+static void AddSegmentRegisterSections(Process &process, ThreadSP &thread_sp,

labath wrote:

Slightly less of a concern, but it still isn't right as this is still used for 
architectures without segment registers. It's also completely avoidable -- you 
could just call this "AddThreadLocalMemoryRegions" or something like that..

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


[Lldb-commits] [lldb] [LLDB][Minidump] Have Minidumps save off and properly read TLS data (PR #109477)

2024-10-10 Thread Pavel Labath via lldb-commits

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


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


[Lldb-commits] [lldb] [LLDB][Minidump] Have Minidumps save off and properly read TLS data (PR #109477)

2024-10-10 Thread Pavel Labath via lldb-commits


@@ -83,7 +83,11 @@ ModuleSP DynamicLoader::GetTargetExecutable() {
   ModuleSpec module_spec(executable->GetFileSpec(),
  executable->GetArchitecture());
   auto module_sp = std::make_shared(module_spec);
-
+  // If we're a coredump and we already have a main executable, we don't
+  // need to reload the module list that target already has

labath wrote:

Ok, I see. I'm not entirely happy by this, but it sort of makes sense, so I'm 
willing to look the other way. :P

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


[Lldb-commits] [lldb] [lldb][test] elf-memory.test requires LLDB build with Python support (PR #111810)

2024-10-10 Thread David Spickett via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] 99cec7f - [lldb][test] elf-memory.test requires LLDB build with Python support (#111810)

2024-10-10 Thread via lldb-commits

Author: Alex Bradbury
Date: 2024-10-10T12:01:49+01:00
New Revision: 99cec7ff8eabbec929d3d0b3a15b272867cf2a46

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

LOG: [lldb][test] elf-memory.test requires LLDB build with Python support 
(#111810)

Otherwise it fails with "error: Embedded script interpreter unavailable.
LLDB was built without scripting language support."

Added: 


Modified: 
lldb/test/Shell/ObjectFile/ELF/elf-memory.test

Removed: 




diff  --git a/lldb/test/Shell/ObjectFile/ELF/elf-memory.test 
b/lldb/test/Shell/ObjectFile/ELF/elf-memory.test
index 0b1c01486a4b43..75a68edd2d3496 100644
--- a/lldb/test/Shell/ObjectFile/ELF/elf-memory.test
+++ b/lldb/test/Shell/ObjectFile/ELF/elf-memory.test
@@ -1,4 +1,4 @@
-// REQUIRES: system-linux, native
+// REQUIRES: system-linux, native, python
 
 // This test verifies that loading an ELF file from memory works and the new
 // features that were added when loading from memory work like:



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


[Lldb-commits] [lldb] [lldb][test] elf-memory.test requires LLDB build with Python support (PR #111810)

2024-10-10 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] Add SBDebugger:: AddNotificationCallback API (PR #111206)

2024-10-10 Thread Pavel Labath via lldb-commits


@@ -1024,6 +1024,46 @@ static void 
LLDBSwigPythonCallPythonLogOutputCallback(const char *str,
   }
 }
 
+// For NotificationCallback functions
+static void LLDBSwigPythonCallPythonSBNotificationCallback(
+  lldb::NotificationType type, lldb::SBDebugger &debugger, 
+  lldb::SBExecutionContext &exe_ctx, void *baton) {
+  
+  if (baton != Py_None) {
+SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+
+// Convert debugger and exe_ctx to Python objects
+PythonObject debugger_arg = SWIGBridge::ToSWIGWrapper(
+  std::make_unique(debugger));  // Wrap debugger reference
+
+PythonObject exe_ctx_arg = SWIGBridge::ToSWIGWrapper(
+  std::make_unique(exe_ctx));  // Wrap ExecutionContext
+
+// Create a tuple of arguments (type, debugger, exe_ctx)
+PyObject *args = PyTuple_New(3);
+
+// Add NotificationType as an integer to the tuple
+PyTuple_SetItem(args, 0, PyLong_FromLong(static_cast(type)));
+
+// Add debugger and exe_ctx to the tuple
+Py_INCREF(debugger_arg.get());
+PyTuple_SetItem(args, 1, debugger_arg.get());
+
+Py_INCREF(exe_ctx_arg.get());
+PyTuple_SetItem(args, 2, exe_ctx_arg.get());
+
+// Call the Python function with the tuple of arguments (type, debugger, 
exe_ctx)
+PyObject *result = PyObject_CallFunction(
+reinterpret_cast(baton), const_cast("O"), 
args);
+
+// Clean up
+Py_XDECREF(result);
+Py_DECREF(args);  // Decrement reference count for args

labath wrote:

Could this use PythonObject wrappers instead?

Something like `PythonCallable(baton)(PythonInteger(type), debugger_arg, 
exe_ctx_arg)` ?

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


[Lldb-commits] [lldb] Add SBDebugger:: AddNotificationCallback API (PR #111206)

2024-10-10 Thread Pavel Labath via lldb-commits


@@ -1703,6 +1703,30 @@ void SBDebugger::SetDestroyCallback(
   }
 }
 
+lldb::callback_token_t SBDebugger::AddNotificationCallback(
+lldb::NotificationType type,
+lldb::SBNotificationCallback notification_callback, void *baton) {
+  LLDB_INSTRUMENT_VA(type, notification_callback, baton);
+
+  NotificationCallback callback = [](lldb::NotificationType type,
+ lldb::DebuggerSP debugger,
+ lldb::ExecutionContextRefSP exe_ctx,
+ void *baton, void *original_callback) {
+SBDebugger sb_debugger(debugger);
+lldb::SBNotificationCallback original_callback_func =
+(lldb::SBNotificationCallback)original_callback;
+SBExecutionContext sb_exe_ctx(exe_ctx);
+original_callback_func(type, sb_debugger, sb_exe_ctx, baton);
+  };
+  return Debugger::AddNotificationCallback(type, callback, baton,
+   (void *)notification_callback);

labath wrote:

same here

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


[Lldb-commits] [lldb] Add SBDebugger:: AddNotificationCallback API (PR #111206)

2024-10-10 Thread Pavel Labath via lldb-commits


@@ -739,16 +745,29 @@ DebuggerSP 
Debugger::CreateInstance(lldb::LogOutputCallback log_callback,
 g_debugger_list_ptr->push_back(debugger_sp);
   }
   debugger_sp->InstanceInitialize();
+
+  InvokeNotificationCallbacks(debugger_sp, lldb::eDebuggerWillBeCreated);
   return debugger_sp;
 }
 
+void Debugger::InvokeNotificationCallbacks(DebuggerSP debugger_sp,
+   lldb::NotificationType notify_type) 
{
+  std::lock_guard guard(s_notification_callback_mutex);
+  for (const auto &callback_info : s_notification_callbacks) {
+if ((callback_info.type & notify_type) == notify_type)
+  callback_info.callback(notify_type, debugger_sp, nullptr,
+ callback_info.baton,
+ callback_info.original_callback);
+  }
+}
+
 void Debugger::HandleDestroyCallback() {
   const lldb::user_id_t user_id = GetID();
   // Invoke and remove all the callbacks in an FIFO order. Callbacks which are
   // added during this loop will be appended, invoked and then removed last.
   // Callbacks which are removed during this loop will not be invoked.
   while (true) {
-DestroyCallbackInfo callback_info;
+CallbackInfo callback_info;

labath wrote:

How about treating the destroy callbacks as (legacy) synonyms for 
NotificationCallbacks of the "destroy" kind?

Basically, have `SBDebugger::AddDestroyCallback` do a 
`AddNotificationCallback(eDebuggerWillBeDestroyed, callback, baton)`

Then we could delete all of this code...

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


[Lldb-commits] [lldb] Add SBDebugger:: AddNotificationCallback API (PR #111206)

2024-10-10 Thread Pavel Labath via lldb-commits


@@ -1703,6 +1703,30 @@ void SBDebugger::SetDestroyCallback(
   }
 }
 
+lldb::callback_token_t SBDebugger::AddNotificationCallback(
+lldb::NotificationType type,
+lldb::SBNotificationCallback notification_callback, void *baton) {
+  LLDB_INSTRUMENT_VA(type, notification_callback, baton);
+
+  NotificationCallback callback = [](lldb::NotificationType type,
+ lldb::DebuggerSP debugger,
+ lldb::ExecutionContextRefSP exe_ctx,
+ void *baton, void *original_callback) {
+SBDebugger sb_debugger(debugger);
+lldb::SBNotificationCallback original_callback_func =
+(lldb::SBNotificationCallback)original_callback;

labath wrote:

```suggestion
auto original_callback_func =
reinterpret_cast(original_callback);
```

(use c++ cast, and avoid repeating the type)

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


[Lldb-commits] [lldb] Add SBDebugger:: AddNotificationCallback API (PR #111206)

2024-10-10 Thread Pavel Labath via lldb-commits


@@ -1362,6 +1362,12 @@ enum Severity {
   eSeverityInfo, // Equivalent to Remark used in clang.
 };
 
+enum NotificationType {
+  eDebuggerWillBeCreated = (1 << 0),
+  eDebuggerWillBeDestroyed =
+  (1 << 1), // Call before debugger object is destroyed

labath wrote:

Do we actually want to treat this as a bitfield? If not, maybe they should just 
get the usual sequential numbers?

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


[Lldb-commits] [lldb] Add SBDebugger:: AddNotificationCallback API (PR #111206)

2024-10-10 Thread Pavel Labath via lldb-commits


@@ -739,16 +745,29 @@ DebuggerSP 
Debugger::CreateInstance(lldb::LogOutputCallback log_callback,
 g_debugger_list_ptr->push_back(debugger_sp);
   }
   debugger_sp->InstanceInitialize();
+
+  InvokeNotificationCallbacks(debugger_sp, lldb::eDebuggerWillBeCreated);
   return debugger_sp;
 }
 
+void Debugger::InvokeNotificationCallbacks(DebuggerSP debugger_sp,
+   lldb::NotificationType notify_type) 
{
+  std::lock_guard guard(s_notification_callback_mutex);
+  for (const auto &callback_info : s_notification_callbacks) {
+if ((callback_info.type & notify_type) == notify_type)
+  callback_info.callback(notify_type, debugger_sp, nullptr,

labath wrote:

Note this will deadlock if any of the callbacks try to register _another_ 
callback.

You may want to consider making a copy of the list and iterating over *that* 
(without holding the mutex).

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


[Lldb-commits] [lldb] Add SBDebugger:: AddNotificationCallback API (PR #111206)

2024-10-10 Thread Pavel Labath via lldb-commits

labath wrote:

(This is in reply to Jim's comment 
[here](https://github.com/llvm/llvm-project/pull/111206#issuecomment-2400376223).
 I can't quote it, because github garbles it beyond recognition, probably 
because it was sent by email :/)

You're right, I have misunderstood the intention. The thing that threw me off 
was the discussion of about the callback signature (which still looks like it 
wants to be universal). Given that, I'd like to agree with what you said in the 
last part of your email -- I think it'd be better for the callback signatures 
to not be universal as well (no one-signature-to-rule-them-all). Here are my 
reasons for that:
- we sidestep the "should execution context contain a debugger" question -- the 
debugger callback type can just take a debugger argument, and that's it. A 
thread callback type can take an SBThread instead of getting an 
SBExecutionContext and wondering what's inside it.
- we sidestep the "what is the scope of lower-level callback types" question -- 
it's clear that debugger lifetime callbacks have to be global, but for example, 
I think it would be reasonable to have e.g. target creation callbacks scoped to 
the debugger they are being created in (so you can monitor targets in one 
debugger but not interfere with other debuggers you possibly know nothing 
about). With the current design we're basically committing to global callbacks, 
but with the other one, we leave the option open.
- we can pass event-specific data to the callbacks. For example, for my use 
case, the ideal event type would be "module got added to a target" (basically, 
a synchronous version of (eBroadcastBitModulesLoaded) or "target's executable 
module has changed". Fitting that into a universal callback type would be very 
tricky.

If we do this right, I don't believe this should result in a lot of duplicated 
code, as we could write (template?) code to handle the (de)registration in a 
generic way.

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


[Lldb-commits] [lldb] [lldb][test] Use $(STRIP) instead of strip in API tests (PR #111816)

2024-10-10 Thread Pavel Labath via lldb-commits

labath wrote:

> Environment variables for LLVM utils are passed to make on Darwin as well.

Technically, these are `make` variables, right?

https://github.com/llvm/llvm-project/pull/111816
___
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 XCOFF Object File Header for AIX (PR #111814)

2024-10-10 Thread Dhruv Srivastava via lldb-commits

DhruvSrivastavaX wrote:

> A couple of quick notes:
> 
> * are you sure that ObjectFileELF is the best thing to start with here? Based 
> on the name, I would expect that ObjectFilePECOFF would be a better baseline. 
> Or maybe the object file format is different enough from all of the existing 
> ones that this kind of comparison is not useful?
> * without also seeing the cpp file, it hard to judge how similar it is to the 
> other plugin
> * instead of redeclaring all the header types, would it be possible to use 
> some structures from llvm? (I know that ObjectFileELF does not do that, but 
> that's because it is very old. ObjectFilePECOFF -- a much newer class -- does 
> just that)
> * a lot of the object file code should be testable on its own. If you include 
> the necessary plugin glue in this PR, then you should be able to write tests 
> similar to those in `lldb/test/Shell/ObjectFile`. For example, if you could 
> start with a test similar to `test/Shell/ObjectFile/ELF/basic-info.yaml` and 
> then include enough of code in the PR to make that pass.

Hi @labath , 

1. Actually there might be slight similarities with ObjectFilePECOFF, but the 
overall format structure is very different to be compared to any one of the 
existing formats, so I have just taken the ObjectFileELF.h as a base to follow 
the general class/file arrangement. 
2. As per our last discussion, I have planned to drop each of the major files 
separately, so I can push the .cpp file as another commit, and both of these 
can be used for comparison. 
3. From a surface level I can see that ObjectFilePECOFF has also created its 
own new structures based on its file format, essentially we have done something 
similar for XCOFF. Although, let me check the existing llvm structures for 
XCOFF thoroughly and get back to you on this. 
4. So, as per your suggestion, what path flow should we take? 
Based on previous discussions, as of now I am planning a commit for .h file, 
another commit for .cpp file and a final commit for the test cases. Is that 
okay?

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


[Lldb-commits] [lldb] [lldb][test] Use $(STRIP) instead of strip in API tests (Darwin-only change) (PR #111816)

2024-10-10 Thread Vladislav Dzhidzhoev via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Log errors to the system log if they would otherwise get dropped (PR #111911)

2024-10-10 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

I considered *always* logging to the system log, but copying errors is a bit 
tricky. I could reuse the logic that Adrian added to status, but wanted to 
gather your input. Regardless, I tried this out locally by debugging the 
`count` tool and this already reported a bunch of errors that would have 
otherwise gone unnoticed. I haven't looked at them in detail but these were all 
things I've never seen before. 

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


[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)

2024-10-10 Thread Igor Kudrin via lldb-commits

https://github.com/igorkudrin updated 
https://github.com/llvm/llvm-project/pull/111237

>From 6756842b1c78ac6f41fa467f112aa7632f260582 Mon Sep 17 00:00:00 2001
From: Igor Kudrin 
Date: Fri, 4 Oct 2024 23:27:04 -0700
Subject: [PATCH 1/3] [lldb] Fix and re-enable TestUseSourceCache.py

The decorators caused the main test, i.e. `test_set_use_source_cache_true()`,
to be skipped in most scenarios. In fact, it was only run on a Windows host
targeting a non-Windows remote platform, and it failed in this case because
the source file is opened with the `FILE_SHARE_DELETE` share mode, which
allows the file to be removed, see `llvm::sys::fs::openNativeFileInternal()`
in `llvm/lib/Support/Windows/Path.inc`.

This patch changes the test to check that the content can still be displayed
even after deleting the file when caching is enabled. The updated test is
expected to work on any platform, so the decorators are removed.
---
 .../settings/use_source_cache/TestUseSourceCache.py   | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git 
a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py 
b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
index 421599080a9e51..421b13f253f05b 100644
--- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
+++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
@@ -17,8 +17,6 @@ def test_set_use_source_cache_false(self):
 """Test that after 'set use-source-cache false', files are not 
locked."""
 self.set_use_source_cache_and_test(False)
 
-@skipIf(hostoslist=no_match(["windows"]))
-@skipIf(oslist=["windows"])  # Fails on windows 11
 def test_set_use_source_cache_true(self):
 """Test that after 'set use-source-cache false', files are locked."""
 self.set_use_source_cache_and_test(True)
@@ -43,16 +41,15 @@ def set_use_source_cache_and_test(self, is_cache_enabled):
 self, "calc"
 )
 
-# Show the source file contents to make sure LLDB loads src file.
-self.runCmd("source list")
+# Ensure that the source file is loaded.
+self.expect("step", patterns=["-> .+ int x4 ="])
 
 # Try deleting the source file.
 is_file_removed = self.removeFile(src)
 
 if is_cache_enabled:
-self.assertFalse(
-is_file_removed, "Source cache is enabled, but delete file 
succeeded"
-)
+# Regardless of whether the file is removed, its contents should 
be displayed.
+self.expect("step", patterns=["-> .+ int x5 ="])
 
 if not is_cache_enabled:
 self.assertTrue(

>From ef848fd2c7de9483cfe2cb0286a20df0a2005f97 Mon Sep 17 00:00:00 2001
From: Igor Kudrin 
Date: Tue, 8 Oct 2024 22:16:23 -0700
Subject: [PATCH 2/3] `removeFile()` -> `overwriteFile()`

---
 .../use_source_cache/TestUseSourceCache.py| 26 +++
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git 
a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py 
b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
index 421b13f253f05b..0c005ff3ab21b1 100644
--- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
+++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
@@ -17,8 +17,9 @@ def test_set_use_source_cache_false(self):
 """Test that after 'set use-source-cache false', files are not 
locked."""
 self.set_use_source_cache_and_test(False)
 
+@skipIf(hostoslist=no_match(["windows"]))
 def test_set_use_source_cache_true(self):
-"""Test that after 'set use-source-cache false', files are locked."""
+"""Test that after 'set use-source-cache true', files are locked."""
 self.set_use_source_cache_and_test(True)
 
 def set_use_source_cache_and_test(self, is_cache_enabled):
@@ -41,25 +42,28 @@ def set_use_source_cache_and_test(self, is_cache_enabled):
 self, "calc"
 )
 
-# Ensure that the source file is loaded.
-self.expect("step", patterns=["-> .+ int x4 ="])
+# Show the source file contents to make sure LLDB loads src file.
+self.runCmd("source list")
 
-# Try deleting the source file.
-is_file_removed = self.removeFile(src)
+# Try overwriting the source file.
+is_file_overwritten = self.overwriteFile(src)
 
 if is_cache_enabled:
-# Regardless of whether the file is removed, its contents should 
be displayed.
-self.expect("step", patterns=["-> .+ int x5 ="])
+self.assertFalse(
+is_file_overwritten, "Source cache is enabled, but writing to 
file succeeded"
+)
 
 if not is_cache_enabled:
 self.assertTrue(
-is_file_removed, "Source cache is disabled, but delete file 
failed"
+is_file_overwritten, "Source cache is 

[Lldb-commits] [lldb] [lldb] Fix and re-enable TestUseSourceCache.py (PR #111237)

2024-10-10 Thread Igor Kudrin via lldb-commits

https://github.com/igorkudrin updated 
https://github.com/llvm/llvm-project/pull/111237

>From 6756842b1c78ac6f41fa467f112aa7632f260582 Mon Sep 17 00:00:00 2001
From: Igor Kudrin 
Date: Fri, 4 Oct 2024 23:27:04 -0700
Subject: [PATCH 1/3] [lldb] Fix and re-enable TestUseSourceCache.py

The decorators caused the main test, i.e. `test_set_use_source_cache_true()`,
to be skipped in most scenarios. In fact, it was only run on a Windows host
targeting a non-Windows remote platform, and it failed in this case because
the source file is opened with the `FILE_SHARE_DELETE` share mode, which
allows the file to be removed, see `llvm::sys::fs::openNativeFileInternal()`
in `llvm/lib/Support/Windows/Path.inc`.

This patch changes the test to check that the content can still be displayed
even after deleting the file when caching is enabled. The updated test is
expected to work on any platform, so the decorators are removed.
---
 .../settings/use_source_cache/TestUseSourceCache.py   | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git 
a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py 
b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
index 421599080a9e51..421b13f253f05b 100644
--- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
+++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
@@ -17,8 +17,6 @@ def test_set_use_source_cache_false(self):
 """Test that after 'set use-source-cache false', files are not 
locked."""
 self.set_use_source_cache_and_test(False)
 
-@skipIf(hostoslist=no_match(["windows"]))
-@skipIf(oslist=["windows"])  # Fails on windows 11
 def test_set_use_source_cache_true(self):
 """Test that after 'set use-source-cache false', files are locked."""
 self.set_use_source_cache_and_test(True)
@@ -43,16 +41,15 @@ def set_use_source_cache_and_test(self, is_cache_enabled):
 self, "calc"
 )
 
-# Show the source file contents to make sure LLDB loads src file.
-self.runCmd("source list")
+# Ensure that the source file is loaded.
+self.expect("step", patterns=["-> .+ int x4 ="])
 
 # Try deleting the source file.
 is_file_removed = self.removeFile(src)
 
 if is_cache_enabled:
-self.assertFalse(
-is_file_removed, "Source cache is enabled, but delete file 
succeeded"
-)
+# Regardless of whether the file is removed, its contents should 
be displayed.
+self.expect("step", patterns=["-> .+ int x5 ="])
 
 if not is_cache_enabled:
 self.assertTrue(

>From ef848fd2c7de9483cfe2cb0286a20df0a2005f97 Mon Sep 17 00:00:00 2001
From: Igor Kudrin 
Date: Tue, 8 Oct 2024 22:16:23 -0700
Subject: [PATCH 2/3] `removeFile()` -> `overwriteFile()`

---
 .../use_source_cache/TestUseSourceCache.py| 26 +++
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git 
a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py 
b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
index 421b13f253f05b..0c005ff3ab21b1 100644
--- a/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
+++ b/lldb/test/API/commands/settings/use_source_cache/TestUseSourceCache.py
@@ -17,8 +17,9 @@ def test_set_use_source_cache_false(self):
 """Test that after 'set use-source-cache false', files are not 
locked."""
 self.set_use_source_cache_and_test(False)
 
+@skipIf(hostoslist=no_match(["windows"]))
 def test_set_use_source_cache_true(self):
-"""Test that after 'set use-source-cache false', files are locked."""
+"""Test that after 'set use-source-cache true', files are locked."""
 self.set_use_source_cache_and_test(True)
 
 def set_use_source_cache_and_test(self, is_cache_enabled):
@@ -41,25 +42,28 @@ def set_use_source_cache_and_test(self, is_cache_enabled):
 self, "calc"
 )
 
-# Ensure that the source file is loaded.
-self.expect("step", patterns=["-> .+ int x4 ="])
+# Show the source file contents to make sure LLDB loads src file.
+self.runCmd("source list")
 
-# Try deleting the source file.
-is_file_removed = self.removeFile(src)
+# Try overwriting the source file.
+is_file_overwritten = self.overwriteFile(src)
 
 if is_cache_enabled:
-# Regardless of whether the file is removed, its contents should 
be displayed.
-self.expect("step", patterns=["-> .+ int x5 ="])
+self.assertFalse(
+is_file_overwritten, "Source cache is enabled, but writing to 
file succeeded"
+)
 
 if not is_cache_enabled:
 self.assertTrue(
-is_file_removed, "Source cache is disabled, but delete file 
failed"
+is_file_overwritten, "Source cache is 

[Lldb-commits] [lldb] f02252e - Revert "[lldb] SetErrorStringWithFormatv -> FromErrorStringWithFormatv (NFC)"

2024-10-10 Thread Augusto Noronha via lldb-commits

Author: Augusto Noronha
Date: 2024-10-10T15:05:58-07:00
New Revision: f02252e1fd2965db007cf7be74c448b7a119c321

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

LOG: Revert "[lldb] SetErrorStringWithFormatv -> FromErrorStringWithFormatv 
(NFC)"

This reverts commit b77fdf5799be6b29869f2f7969851709e03938ba.

Added: 


Modified: 
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp 
b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index 367fce442bb866..116c43343c01d1 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -407,9 +407,8 @@ Status ProcessKDP::DoResume(RunDirection direction) {
   Log *log = GetLog(KDPLog::Process);
 
   if (direction == RunDirection::eRunReverse) {
-error.FromErrorStringWithFormatv(
-"error: {0} does not support reverse execution of processes",
-GetPluginName());
+error.SetErrorStringWithFormatv(
+"error: {0} does not support reverse execution of processes", 
GetPluginName());
 return error;
   }
 



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


[Lldb-commits] [lldb] 2ff4c25 - Revert "[lldb] Implement basic support for reverse-continue (#99736)"

2024-10-10 Thread Augusto Noronha via lldb-commits

Author: Augusto Noronha
Date: 2024-10-10T15:05:58-07:00
New Revision: 2ff4c25b7efff64b3b662d0bedcfe7edebcf20b9

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

LOG: Revert "[lldb] Implement basic support for reverse-continue (#99736)"

This reverts commit d5e1de6da96c1ab3b8cae68447e8ed3696a7006e.

Added: 


Modified: 
lldb/include/lldb/API/SBProcess.h
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Target/StopInfo.h
lldb/include/lldb/lldb-enumerations.h
lldb/packages/Python/lldbsuite/test/gdbclientutils.py
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/source/API/SBProcess.cpp
lldb/source/API/SBThread.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
lldb/source/Plugins/Process/scripted/ScriptedProcess.h
lldb/source/Target/Process.cpp
lldb/source/Target/StopInfo.cpp
lldb/source/Target/Thread.cpp
lldb/tools/lldb-dap/JSONUtils.cpp
lldb/tools/lldb-dap/LLDBUtils.cpp

Removed: 
lldb/packages/Python/lldbsuite/test/lldbgdbproxy.py
lldb/packages/Python/lldbsuite/test/lldbreverse.py
lldb/test/API/functionalities/reverse-execution/Makefile

lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py

lldb/test/API/functionalities/reverse-execution/TestReverseContinueNotSupported.py
lldb/test/API/functionalities/reverse-execution/main.c



diff  --git a/lldb/include/lldb/API/SBProcess.h 
b/lldb/include/lldb/API/SBProcess.h
index 8b8ed830b54cc0..1624e02070b1b2 100644
--- a/lldb/include/lldb/API/SBProcess.h
+++ b/lldb/include/lldb/API/SBProcess.h
@@ -159,7 +159,6 @@ class LLDB_API SBProcess {
   lldb::SBError Destroy();
 
   lldb::SBError Continue();
-  lldb::SBError Continue(RunDirection direction);
 
   lldb::SBError Stop();
 

diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index fe7fbc50fd5770..b8c53a474ba6b9 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -857,10 +857,10 @@ class Process : public 
std::enable_shared_from_this,
   /// \see Thread:Resume()
   /// \see Thread:Step()
   /// \see Thread:Suspend()
-  Status Resume(lldb::RunDirection direction = lldb::eRunForward);
+  Status Resume();
 
   /// Resume a process, and wait for it to stop.
-  Status ResumeSynchronous(Stream *stream, lldb::RunDirection direction = 
lldb::eRunForward);
+  Status ResumeSynchronous(Stream *stream);
 
   /// Halts a running process.
   ///
@@ -1104,14 +1104,9 @@ class Process : public 
std::enable_shared_from_this,
   /// \see Thread:Resume()
   /// \see Thread:Step()
   /// \see Thread:Suspend()
-  virtual Status DoResume(lldb::RunDirection direction) {
-if (direction == lldb::RunDirection::eRunForward) {
-  return Status::FromErrorStringWithFormatv(
-  "error: {0} does not support resuming processes", GetPluginName());
-} else {
-  return Status::FromErrorStringWithFormatv(
-  "error: {0} does not support reverse execution of processes", 
GetPluginName());
-}
+  virtual Status DoResume() {
+return Status::FromErrorStringWithFormatv(
+"error: {0} does not support resuming processes", GetPluginName());
   }
 
   /// Called after resuming a process.
@@ -2337,8 +2332,6 @@ class Process : public 
std::enable_shared_from_this,
 
   bool IsRunning() const;
 
-  lldb::RunDirection GetLastRunDirection() { return m_last_run_direction; }
-
   DynamicCheckerFunctions *GetDynamicCheckers() {
 return m_dynamic_checkers_up.get();
   }
@@ -2858,7 +2851,7 @@ void PruneThreadPlans();
   ///
   /// \return
   /// An Status object describing the success or failure of the resume.
-  Status PrivateResume(lldb::RunDirection direction = lldb::eRunForward);
+  Status PrivateResume();
 
   // Called internally
   void CompleteAttach();
@@ -3134,8 +3127,6 @@ void PruneThreadPlans();
// m_currently_handling_do_on_removals are true,
// Resume will only request a resume, using this
// fla

[Lldb-commits] [lldb] [lldb] Log errors to the system log if they would otherwise get dropped (PR #111911)

2024-10-10 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

To clone an error, do Status::FromError(error). Every call to Status::toError() 
clones the error (as opposed to takeError()). Generally we want to avoid 
cloning errors though.

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


[Lldb-commits] [lldb] e9c8f75 - [LLDB][Minidump] Have Minidumps save off and properly read TLS data (#109477)

2024-10-10 Thread via lldb-commits

Author: Jacob Lalonde
Date: 2024-10-10T15:59:51-07:00
New Revision: e9c8f75d45ababe7f805078bbf7bda2e7425f1b7

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

LOG: [LLDB][Minidump] Have Minidumps save off and properly read TLS data 
(#109477)

This patch adds the support to `Process.cpp` to automatically save off
TLS sections, either via loading the memory region for the module, or
via reading `fs_base` via generic register. Then when Minidumps are
loaded, we now specify we want the dynamic loader to be the `POSIXDYLD`
so we can leverage the same TLS accessor code as `ProcessELFCore`. Being
able to access TLS Data is an important step for LLDB generated
minidumps to have feature parity with ELF Core dumps.

Added: 


Modified: 
lldb/include/lldb/Target/DynamicLoader.h
lldb/source/Core/DynamicLoader.cpp
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h
lldb/source/Plugins/Process/minidump/ProcessMinidump.cpp
lldb/source/Plugins/Process/minidump/ProcessMinidump.h
lldb/source/Plugins/Process/minidump/RegisterContextMinidump_x86_64.cpp
lldb/source/Target/Process.cpp

lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
lldb/test/API/functionalities/process_save_core_minidump/main.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/DynamicLoader.h 
b/lldb/include/lldb/Target/DynamicLoader.h
index 0629e2faae7e9e..75bb6cb6bb9074 100644
--- a/lldb/include/lldb/Target/DynamicLoader.h
+++ b/lldb/include/lldb/Target/DynamicLoader.h
@@ -11,6 +11,7 @@
 
 #include "lldb/Core/Address.h"
 #include "lldb/Core/PluginInterface.h"
+#include "lldb/Target/CoreFileMemoryRanges.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/UUID.h"
@@ -337,6 +338,17 @@ class DynamicLoader : public PluginInterface {
 return std::nullopt;
   }
 
+  /// Returns a list of memory ranges that should be saved in the core file,
+  /// specific for this dynamic loader.
+  ///
+  /// For example, an implementation of this function can save the thread
+  /// local data of a given thread.
+  virtual void CalculateDynamicSaveCoreRanges(
+  lldb_private::Process &process,
+  std::vector &ranges,
+  llvm::function_ref
+  save_thread_predicate) {};
+
 protected:
   // Utility methods for derived classes
 

diff  --git a/lldb/source/Core/DynamicLoader.cpp 
b/lldb/source/Core/DynamicLoader.cpp
index 7758a87403b5a3..68d6ab0850853f 100644
--- a/lldb/source/Core/DynamicLoader.cpp
+++ b/lldb/source/Core/DynamicLoader.cpp
@@ -83,7 +83,11 @@ ModuleSP DynamicLoader::GetTargetExecutable() {
   ModuleSpec module_spec(executable->GetFileSpec(),
  executable->GetArchitecture());
   auto module_sp = std::make_shared(module_spec);
-
+  // If we're a coredump and we already have a main executable, we don't
+  // need to reload the module list that target already has
+  if (!m_process->IsLiveDebugSession()) {
+return executable;
+  }
   // Check if the executable has changed and set it to the target
   // executable if they 
diff er.
   if (module_sp && module_sp->GetUUID().IsValid() &&
@@ -369,4 +373,3 @@ void DynamicLoader::LoadOperatingSystemPlugin(bool flush)
 if (m_process)
 m_process->LoadOperatingSystemPlugin(flush);
 }
-

diff  --git 
a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index b9c0e174c3be68..34aca50df0ac4b 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -18,6 +18,7 @@
 #include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Target/MemoryRegionInfo.h"
 #include "lldb/Target/Platform.h"
+#include "lldb/Target/RegisterContext.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Target/ThreadPlanRunToAddress.h"
@@ -866,3 +867,82 @@ bool DynamicLoaderPOSIXDYLD::AlwaysRelyOnEHUnwindInfo(
 bool DynamicLoaderPOSIXDYLD::IsCoreFile() const {
   return !m_process->IsLiveDebugSession();
 }
+
+// For our ELF/POSIX builds save off the fs_base/gs_base regions
+static void AddThreadLocalMemoryRegions(Process &process, ThreadSP &thread_sp,
+std::vector &ranges) 
{
+  lldb::RegisterContextSP reg_ctx = thread_sp->GetRegisterContext();
+  if (!reg_ctx)
+return;
+
+  const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(
+  lldb::RegisterKind::eRegisterKindGeneric, LLDB_REGNUM_GENERIC_TP);
+  if (!reg_info)
+return;
+
+  lldb_private::

[Lldb-commits] [lldb] [LLDB][Minidump] Have Minidumps save off and properly read TLS data (PR #109477)

2024-10-10 Thread Jacob Lalonde via lldb-commits

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


[Lldb-commits] [lldb] Support inline diagnostics in CommandReturnObject (PR #110901)

2024-10-10 Thread via lldb-commits


@@ -0,0 +1,79 @@
+//===-- DiagnosticsRendering.h --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_UTILITY_DIAGNOSTICSRENDERING_H
+#define LLDB_UTILITY_DIAGNOSTICSRENDERING_H
+
+#include "lldb/Utility/Status.h"
+#include "lldb/Utility/Stream.h"
+#include "llvm/Support/WithColor.h"
+
+namespace lldb_private {
+
+/// A compiler-independent representation of an \c
+/// lldb_private::Diagnostic. Expression evaluation failures often
+/// have more than one diagnostic that a UI layer might want to render
+/// differently, for example to colorize it.
+///
+/// Running example:
+///   (lldb) expr 1 + foo
+///   error: :1:3: use of undeclared identifier 'foo'
+///   1 + foo
+///   ^~~
+struct DiagnosticDetail {
+  /// A source location consisting of a file name and position.
+  struct SourceLocation {
+/// \c "" in the example above.
+FileSpec file;
+/// \c 1 in the example above.
+unsigned line = 0;
+/// \c 5 in the example above.
+uint16_t column = 0;
+/// \c 3 in the example above.
+uint16_t length = 0;
+/// Whether this source location should be surfaced to the
+/// user. For example, syntax errors diagnosed in LLDB's
+/// expression wrapper code have this set to true.
+bool hidden = false;
+/// Whether this source location refers to something the user
+/// typed as part of the command, i.e., if this qualifies for
+/// inline display, or if the source line would need to be echoed
+/// again for the message to make sense.
+bool in_user_input = false;
+  };
+  /// Contains this diagnostic's source location, if applicable.
+  std::optional source_location;
+  /// Contains \c eSeverityError in the example above.
+  lldb::Severity severity = lldb::eSeverityInfo;
+  /// Contains "use of undeclared identifier 'foo'" in the example above.
+  std::string message;
+  /// Contains the fully rendered error message, without "error: ",
+  /// but including the source context.

jimingham wrote:

You have a bool saying whether this can be used in inline displays, which leads 
to the question "can I get you to make that for me here".  That the answer to 
that is no is fine, butsaying that explicitly would have reduced confusion.  No 
biggie...

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


[Lldb-commits] [lldb] Support inline diagnostics in CommandReturnObject (PR #110901)

2024-10-10 Thread Adrian Prantl via lldb-commits


@@ -160,6 +166,9 @@ class CommandReturnObject {
 
   StreamTee m_out_stream;
   StreamTee m_err_stream;
+  std::vector m_diagnostics;
+  StreamString m_diag_stream;
+  std::optional m_diagnostic_indent;

adrian-prantl wrote:

Because DiagnostcDetails are created in places (e.g., the expression evaluator) 
that don't have any information about driver details like the indent.

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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-10 Thread Stefan Gränitz via lldb-commits


@@ -272,6 +272,8 @@ def parseOptionsAndInitTestdirs():
 configuration.make_path = "gmake"
 else:
 configuration.make_path = "make"
+if ' ' in configuration.make_path:
+configuration.make_path = f'"{configuration.make_path}"'

weliveindetail wrote:

I added this because yesterday my tests failed with:
```
'C:/Program' is not recognized as an internal or external command,
operable program or batch file.
```

I double-checked again today and this doesn't happen anymore. I am not sure 
why, maybe I had an inconsistent configuration state. The parameter for 
dotest.py is `--make C:/Program Files (x86)/GnuWin32/bin/make.exe` and the 
command that lldbtest.py runs is starting with `C:/Program Files 
(x86)/GnuWin32/bin/make.exe VPATH=...`. I cleared the cached in 
`lldb-test-build.noindex` and checked sure the binaries are recreated 
successfully by the test suite. It works without the quotes.

I am attaching a log file 
[TestBreakpointByLineAndColumn.log](https://github.com/user-attachments/files/17326545/TestBreakpointByLineAndColumn.log)
 with the commands dumped for future reference. I will the quoting and assume 
it just keeps working.

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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-10 Thread Stefan Gränitz via lldb-commits

https://github.com/weliveindetail updated 
https://github.com/llvm/llvm-project/pull/111531

From c7356d3c265869ff387c977dd18e9c617dc31c8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Tue, 8 Oct 2024 15:40:37 +0200
Subject: [PATCH 1/7] [lldb] Add early CMake check for 'make' tool

Around 400 of LLDB's dotest.py based tests require the make tool to be found in 
Path. If it's not found, they fail with an obscure error and show up as 
UNRESOLVED.
llvm-lit takes care of MSYS based testing tools like cat, printf, etc., but 
make is not part of that. Let's catch the situation early and raise an error if 
LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS was enabled.
This error is not fatal: It should fail the build, but not immediately stop the 
configuration process. There might be other issues further down the line that 
can be caught in the same buildbot run.
---
 lldb/test/CMakeLists.txt | 12 
 1 file changed, 12 insertions(+)

diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 5ac474736eb63d..7993be2602e538 100644
--- a/lldb/test/CMakeLists.txt
+++ b/lldb/test/CMakeLists.txt
@@ -29,6 +29,18 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
 "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`")
 endif()
   endforeach()
+
+  # On Windows make is not part of the MSYS tools that llvm-lit takes care of
+  find_program(MAKE_TOOL make)
+  if(MAKE_TOOL)
+message(STATUS "Found make: ${MAKE_TOOL}")
+  else()
+message(STATUS "Not found: make")
+message(SEND_ERROR
+  "LLDB tests require 'make' tool. Please install and add it to Path "
+  "(or otherwise disable strict testing requirements with "
+  "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`)")
+  endif()
 endif()
 
 if(LLDB_BUILT_STANDALONE)

From 5e7bc2d26b54440936b3d756e12d708ae5218c4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= 
Date: Wed, 9 Oct 2024 13:07:27 +0200
Subject: [PATCH 2/7] Pass make as an explicit argument to dotest.py

---
 lldb/packages/Python/lldbsuite/test/dotest.py |  2 ++
 lldb/test/API/CMakeLists.txt  |  1 +
 lldb/test/API/lit.cfg.py  |  3 +++
 lldb/test/API/lit.site.cfg.py.in  |  1 +
 lldb/test/CMakeLists.txt  | 20 +++
 5 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index b1ae896d3fd3b4..40294aec166381 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -272,6 +272,8 @@ def parseOptionsAndInitTestdirs():
 configuration.make_path = "gmake"
 else:
 configuration.make_path = "make"
+if ' ' in configuration.make_path:
+configuration.make_path = f'"{configuration.make_path}"'
 
 if args.dsymutil:
 configuration.dsymutil = args.dsymutil
diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 27f285230cafaf..c426d76f7d9e76 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -58,6 +58,7 @@ endif()
 set(LLDB_TEST_EXECUTABLE "${LLDB_DEFAULT_TEST_EXECUTABLE}" CACHE PATH "lldb 
executable used for testing")
 set(LLDB_TEST_COMPILER "${LLDB_DEFAULT_TEST_COMPILER}" CACHE PATH "C Compiler 
to use for building LLDB test inferiors")
 set(LLDB_TEST_DSYMUTIL "${LLDB_DEFAULT_TEST_DSYMUTIL}" CACHE PATH "dsymutil 
used for generating dSYM bundles")
+set(LLDB_TEST_MAKE "${LLDB_DEFAULT_TEST_MAKE}" CACHE PATH "make tool used for 
building test executables")
 
 if ("${LLDB_TEST_COMPILER}" STREQUAL "")
   message(FATAL_ERROR "LLDB test compiler not specified. Tests will not run.")
diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 96520c7c826246..c6fa20a63424d4 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -250,6 +250,9 @@ def delete_module_cache(path):
 if is_configured("dsymutil"):
 dotest_cmd += ["--dsymutil", config.dsymutil]
 
+if is_configured("make"):
+dotest_cmd += ["--make", config.make]
+
 if is_configured("llvm_tools_dir"):
 dotest_cmd += ["--llvm-tools-dir", config.llvm_tools_dir]
 
diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in
index 8b2d09ae41cd2a..9f647034dc9f97 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -31,6 +31,7 @@ config.lldb_executable = 
lit_config.substitute('@LLDB_TEST_EXECUTABLE@')
 config.test_arch = '@LLDB_TEST_ARCH@'
 config.test_compiler = lit_config.substitute('@LLDB_TEST_COMPILER@')
 config.dsymutil = lit_config.substitute('@LLDB_TEST_DSYMUTIL@')
+config.make = lit_config.substitute('@LLDB_TEST_MAKE@')
 config.has_libcxx = @LLDB_HAS_LIBCXX@
 config.libcxx_libs_dir = "@LIBCXX_LIBRARY_DIR@"
 config.libcxx_include_dir = "@LIBCXX_GENERATED_INCLUDE_DIR@"
diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt
index 7993be2602e538..5b00e10af136f1 100644
-

[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-10 Thread Stefan Gränitz via lldb-commits


@@ -250,6 +250,9 @@ def delete_module_cache(path):
 if is_configured("dsymutil"):
 dotest_cmd += ["--dsymutil", config.dsymutil]
 
+if is_configured("make"):
+dotest_cmd += ["--make", config.make]
+

weliveindetail wrote:

Changed in follow-up patch 
https://github.com/llvm/llvm-project/pull/111531/commits/3f6b93d932d9755c668d31b9c75c152bb3599bbe
 We now always detect `make`.

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


[Lldb-commits] [lldb] [lldb] Add early CMake check for 'make' tool (PR #111531)

2024-10-10 Thread Stefan Gränitz via lldb-commits


@@ -29,6 +29,22 @@ if(LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS)
 "`LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=OFF`")
 endif()
   endforeach()
+
+  # On Windows make is not part of the MSYS tools that llvm-lit takes care of
+  if(LLDB_TEST_MAKE)
+set(LLDB_DEFAULT_TEST_MAKE ${LLDB_TEST_MAKE})
+  else()
+find_program(LLDB_DEFAULT_TEST_MAKE make)
+if(LLDB_DEFAULT_TEST_MAKE)
+  message(STATUS "Found make: ${LLDB_DEFAULT_TEST_MAKE}")

weliveindetail wrote:

Yes, in the end it's small enough indeed. Let me abandon 
https://github.com/llvm/llvm-project/pull/111744 and add these changes here.

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


[Lldb-commits] [lldb] [lldb] Generalize make tool detection in CMake (PR #111744)

2024-10-10 Thread Stefan Gränitz via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Generalize make tool detection in CMake (PR #111744)

2024-10-10 Thread Stefan Gränitz via lldb-commits

weliveindetail wrote:

Fixed as part of the earlier PR linked above.

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


  1   2   >