[Lldb-commits] [lldb] [llvm] [LLDB] Add a target.launch-working-dir setting (PR #113521)

2024-11-04 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [LLDB] Add a target.launch-working-dir setting (PR #113521)

2024-11-04 Thread David Spickett via lldb-commits


@@ -201,6 +201,12 @@ let Definition = "target" in {
   def DebugUtilityExpression: Property<"debug-utility-expression", "Boolean">,
 DefaultFalse,
 Desc<"Enable debugging of LLDB-internal utility expressions.">;
+  def LaunchWorkingDir: Property<"launch-working-dir", "String">,
+DefaultStringValue<"">,
+Desc<"A default value for the working directory to use when launching 
processes. "
+ "It's ignored when empty. This setting is only used when the target 
is "
+ "launched. If you change this setting, the new value will only apply 
to "
+ "subsequent launches.">;

DavidSpickett wrote:

"Commands that take an explicit working directory will override this setting." 
or words to that effect.

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


[Lldb-commits] [lldb] [llvm] [LLDB] Add a target.launch-working-dir setting (PR #113521)

2024-11-04 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett commented:

We only have one request for this feature, but the logic of it is clear and GDB 
as an equivalent in `set cwd`: 
https://sourceware.org/gdb/current/onlinedocs/gdb.html/Working-Directory.html

So this looks good to me once the docs are updated.

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


[Lldb-commits] [lldb] [llvm] [LLDB] Add a target.launch-working-dir setting (PR #113521)

2024-11-04 Thread David Spickett via lldb-commits


@@ -201,6 +201,12 @@ let Definition = "target" in {
   def DebugUtilityExpression: Property<"debug-utility-expression", "Boolean">,
 DefaultFalse,
 Desc<"Enable debugging of LLDB-internal utility expressions.">;
+  def LaunchWorkingDir: Property<"launch-working-dir", "String">,
+DefaultStringValue<"">,
+Desc<"A default value for the working directory to use when launching 
processes. "
+ "It's ignored when empty. This setting is only used when the target 
is "

DavidSpickett wrote:

`It is` - contractions are best avoided for informative text.

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


[Lldb-commits] [lldb] [llvm] [LLDB] Add a target.launch-working-dir setting (PR #113521)

2024-11-04 Thread David Spickett via lldb-commits


@@ -691,7 +691,10 @@ let Command = "process launch" in {
   def process_launch_plugin : Option<"plugin", "P">, Arg<"Plugin">,
 Desc<"Name of the process plugin you want to use.">;
   def process_launch_working_dir : Option<"working-dir", "w">, 
Arg<"DirectoryName">,
-Desc<"Set the current working directory to  when running the 
inferior.">;
+Desc<"Set the current working directory to  when running the 
inferior. This setting "
+ "applies only to the current `process launch` invocation. You can use 
the "
+ "`target.launch-working-dir` setting to set a working-dir that is 
persistent "
+ "across launches.">;

DavidSpickett wrote:

"This option" - it's not a setting.

"If `target.launch-working-dir` is set and this option is given, the value of 
this option will be used instead of the setting."

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


[Lldb-commits] [lldb] [lldb] Recommend Python 3.8 as the minimum Python version for LLDB (PR #114807)

2024-11-04 Thread Jonas Devlieghere via lldb-commits


@@ -64,3 +64,10 @@ else()
   Python3_EXECUTABLE
   LLDB_ENABLE_SWIG)
 endif()
+
+set(LLDB_RECOMMENDED_PYTHON "3.8")
+if(Python3_LIBRARIES AND Python3_INCLUDE_DIRS AND Python3_EXECUTABLE AND 
LLDB_ENABLE_SWIG

JDevlieghere wrote:

Can this check `PYTHONANDSWIG_FOUND` to encompass everything on this line? 

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


[Lldb-commits] [lldb] [lldb] Recommend Python 3.8 as the minimum Python version for LLDB (PR #114807)

2024-11-04 Thread David Spickett via lldb-commits


@@ -64,3 +64,10 @@ else()
   Python3_EXECUTABLE
   LLDB_ENABLE_SWIG)
 endif()
+
+set(LLDB_RECOMMENDED_PYTHON "3.8")
+if(Python3_LIBRARIES AND Python3_INCLUDE_DIRS AND Python3_EXECUTABLE AND 
LLDB_ENABLE_SWIG

DavidSpickett wrote:

Done.

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


[Lldb-commits] [lldb] [lldb] Recommend Python 3.8 as the minimum Python version for LLDB (PR #114807)

2024-11-04 Thread David Spickett via lldb-commits

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

>From 12672234d81cc12625d8832fed4937221d37546e Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 4 Nov 2024 14:41:19 +
Subject: [PATCH 1/2] [lldb] Recommend Python 3.8 as the minimum Python version
 for LLDB

See 
https://discourse.llvm.org/t/rfc-lets-document-and-enforce-a-minimum-python-version-for-lldb/82731
for discussions.

This matches LLVM's requirement to run tests. For LLDB 20 there will
be a CMake warning telling builders that from LLDB 21 this will be
a hard requirement. From LLDB 21, it will be an error to try to build
with anything <= 3.8.

So there are no code changes in this commit. Once the llvm 20 branch
is created we can remove some < 3.8 support code.

As always, if you disable Python support you will not get any new
warnings or errors from this change.
---
 lldb/cmake/modules/FindPythonAndSwig.cmake |  7 +
 lldb/docs/resources/build.rst  | 32 +++---
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/lldb/cmake/modules/FindPythonAndSwig.cmake 
b/lldb/cmake/modules/FindPythonAndSwig.cmake
index d62cced0d095e9..2cdd2204ae43cc 100644
--- a/lldb/cmake/modules/FindPythonAndSwig.cmake
+++ b/lldb/cmake/modules/FindPythonAndSwig.cmake
@@ -64,3 +64,10 @@ else()
   Python3_EXECUTABLE
   LLDB_ENABLE_SWIG)
 endif()
+
+set(LLDB_RECOMMENDED_PYTHON "3.8")
+if(Python3_LIBRARIES AND Python3_INCLUDE_DIRS AND Python3_EXECUTABLE AND 
LLDB_ENABLE_SWIG
+   AND "${Python3_VERSION}" VERSION_LESS "${LLDB_RECOMMENDED_PYTHON}")
+  message(WARNING "Using Python ${Python3_VERSION}. ${LLDB_RECOMMENDED_PYTHON} 
"
+  "is recommended and will be required from LLDB 21.")
+endif()
\ No newline at end of file
diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index 33b6a6f79def4b..0ff0a0d7d049e1 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -51,21 +51,21 @@ CMake flag to ``On`` or ``Off`` to force the dependency to 
be enabled or
 disabled. When a dependency is set to ``On`` and can't be found it will cause a
 CMake configuration error.
 
-+---+--+--+
-| Feature   | Description  | 
CMake Flag   |
-+===+==+==+
-| Editline  | Generic line editing, history, Emacs and Vi bindings | 
``LLDB_ENABLE_LIBEDIT``  |
-+---+--+--+
-| Curses| Text user interface  | 
``LLDB_ENABLE_CURSES``   |
-+---+--+--+
-| LZMA  | Lossless data compression| 
``LLDB_ENABLE_LZMA`` |
-+---+--+--+
-| Libxml2   | XML  | 
``LLDB_ENABLE_LIBXML2``  |
-+---+--+--+
-| Python| Python scripting | 
``LLDB_ENABLE_PYTHON``   |
-+---+--+--+
-| Lua   | Lua scripting| 
``LLDB_ENABLE_LUA``  |
-+---+--+--+
++---+--+--+
+| Feature   | Description  
| CMake Flag   |
++===+==+==+
+| Editline  | Generic line editing, history, Emacs and Vi bindings 
| ``LLDB_ENABLE_LIBEDIT``  |
++---+--+--+
+| Curses| Text user interface  
| ``LLDB_ENABLE_CURSES``   |
++---+--+--+
+| LZMA  | Lossless data compression
| ``LLDB_ENABLE_LZMA`` |
++---+--+--+
+| Libxml2   | XML  
| ``LLDB_ENABLE_LIBXML2``  |
++---+

[Lldb-commits] [lldb] Revert "Fix pointer to reference type (#113596)" (PR #114831)

2024-11-04 Thread Pavel Labath via lldb-commits

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

This reverts commit 25909b811a7ddc983d042b15cb54ec271a673d63 due to unresolved 
questions about the behavior of "frame var" and ValueObject in the presence of 
references (see the original patch for discussion).

>From a98e1f6034479800f0c4ea053f9bee854151b04d Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Mon, 4 Nov 2024 17:56:06 +0100
Subject: [PATCH] Revert "Fix pointer to reference type (#113596)"

This reverts commit 25909b811a7ddc983d042b15cb54ec271a673d63 due to
unresolved questions about the behavior of "frame var" and ValueObject
in the presence of references (see the original patch for discussion).
---
 lldb/source/ValueObject/ValueObject.cpp   |  9 
 .../TestCPPDereferencingReferences.py | 21 ---
 .../cpp/dereferencing_references/main.cpp |  2 --
 3 files changed, 32 deletions(-)

diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index aca43175d12fac..4006f6e6fd0a5e 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -2907,15 +2907,6 @@ ValueObjectSP ValueObject::AddressOf(Status &error) {
 
   AddressType address_type = eAddressTypeInvalid;
   const bool scalar_is_load_address = false;
-
-  // For reference type we need to get the address of the object that
-  // it refers to.
-  if (GetCompilerType().IsReferenceType()) {
-ValueObjectSP deref_obj = Dereference(error);
-if (error.Fail() || !deref_obj)
-  return ValueObjectSP();
-return deref_obj->AddressOf(error);
-  }
   addr_t addr = GetAddressOf(scalar_is_load_address, &address_type);
   error.Clear();
   if (addr != LLDB_INVALID_ADDRESS && address_type != eAddressTypeHost) {
diff --git 
a/lldb/test/API/lang/cpp/dereferencing_references/TestCPPDereferencingReferences.py
 
b/lldb/test/API/lang/cpp/dereferencing_references/TestCPPDereferencingReferences.py
index 1374d4e1ec67ab..938fb1a6edf32c 100644
--- 
a/lldb/test/API/lang/cpp/dereferencing_references/TestCPPDereferencingReferences.py
+++ 
b/lldb/test/API/lang/cpp/dereferencing_references/TestCPPDereferencingReferences.py
@@ -25,24 +25,3 @@ def test(self):
 # Typedef to a reference should dereference to the underlying type.
 td_val = self.expect_var_path("td_to_ref_type", type="td_int_ref")
 self.assertEqual(td_val.Dereference().GetType().GetName(), "int")
-
-def test_take_address_of_reference(self):
-"""Tests taking address of lvalue/rvalue references in lldb works 
correctly."""
-self.build()
-lldbutil.run_to_source_breakpoint(
-self, "// break here", lldb.SBFileSpec("main.cpp")
-)
-
-plref_val_from_code = self.expect_var_path("pl_ref", type="TTT *")
-plref_val_from_expr_path = self.expect_var_path("&l_ref", type="TTT *")
-self.assertEqual(
-plref_val_from_code.GetValueAsAddress(),
-plref_val_from_expr_path.GetValueAsAddress(),
-)
-
-prref_val_from_code = self.expect_var_path("pr_ref", type="TTT *")
-prref_val_from_expr_path = self.expect_var_path("&r_ref", type="TTT *")
-self.assertEqual(
-prref_val_from_code.GetValueAsAddress(),
-prref_val_from_expr_path.GetValueAsAddress(),
-)
diff --git a/lldb/test/API/lang/cpp/dereferencing_references/main.cpp 
b/lldb/test/API/lang/cpp/dereferencing_references/main.cpp
index 4ddffd167ddeed..b64978a9029f81 100644
--- a/lldb/test/API/lang/cpp/dereferencing_references/main.cpp
+++ b/lldb/test/API/lang/cpp/dereferencing_references/main.cpp
@@ -9,7 +9,5 @@ int main() {
   // typedef of a reference
   td_int_ref td_to_ref_type = i;
 
-  TTT *pl_ref = &l_ref;
-  TTT *pr_ref = &r_ref;
   return l_ref; // break here
 }

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


[Lldb-commits] [lldb] Fix call site breakpoint patch (PR #114158)

2024-11-04 Thread via lldb-commits

jimingham wrote:

Give me a bit to look at this.  The intention of this patch was just to add 
more locations, it shouldn't be reducing the number of breakpoints.  There's 
likely some simple goof here.

Jim


> On Nov 4, 2024, at 2:44 AM, Pavel Labath ***@***.***> wrote:
> 
> 
> So it sounds like the problem is that lldb no longer looks for all compile 
> units with the given name when setting a breakpoint. Changing that doesn't 
> seem like it was the intention of this patch. Jim, is there an easy fix for 
> this or should we revert the patch for now?
> 
> —
> 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/114158
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [lldb-dap] Support column breakpoints (PR #113787)

2024-11-04 Thread Adrian Vogelsgesang via lldb-commits


@@ -910,6 +911,183 @@ void request_attach(const llvm::json::Object &request) {
   }
 }
 
+// "BreakpointLocationsRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "The `breakpointLocations` request returns all possible
+// locations for source breakpoints in a given range.\nClients should only
+// call this request if the corresponding capability
+// `supportsBreakpointLocationsRequest` is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "breakpointLocations" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/BreakpointLocationsArguments"
+//   }
+// },
+// "required": [ "command" ]
+//   }]
+// },
+// "BreakpointLocationsArguments": {
+//   "type": "object",
+//   "description": "Arguments for `breakpointLocations` request.",
+//   "properties": {
+// "source": {
+//   "$ref": "#/definitions/Source",
+//   "description": "The source location of the breakpoints; either
+//   `source.path` or `source.sourceReference` must be specified."
+// },
+// "line": {
+//   "type": "integer",
+//   "description": "Start line of range to search possible breakpoint
+//   locations in. If only the line is specified, the request returns all
+//   possible locations in that line."
+// },
+// "column": {
+//   "type": "integer",
+//   "description": "Start position within `line` to search possible
+//   breakpoint locations in. It is measured in UTF-16 code units and the
+//   client capability `columnsStartAt1` determines whether it is 0- or
+//   1-based. If no column is given, the first position in the start line 
is
+//   assumed."
+// },
+// "endLine": {
+//   "type": "integer",
+//   "description": "End line of range to search possible breakpoint
+//   locations in. If no end line is given, then the end line is assumed to
+//   be the start line."
+// },
+// "endColumn": {
+//   "type": "integer",
+//   "description": "End position within `endLine` to search possible
+//   breakpoint locations in. It is measured in UTF-16 code units and the
+//   client capability `columnsStartAt1` determines whether it is 0- or
+//   1-based. If no end column is given, the last position in the end line
+//   is assumed."
+// }
+//   },
+//   "required": [ "source", "line" ]
+// },
+// "BreakpointLocationsResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to `breakpointLocations` request.\nContains
+// possible locations for source breakpoints.",
+// "properties": {
+//   "body": {
+// "type": "object",
+// "properties": {
+//   "breakpoints": {
+// "type": "array",
+// "items": {
+//   "$ref": "#/definitions/BreakpointLocation"
+// },
+// "description": "Sorted set of possible breakpoint locations."
+//   }
+// },
+// "required": [ "breakpoints" ]
+//   }
+// },
+// "required": [ "body" ]
+//   }]
+// },
+// "BreakpointLocation": {
+//   "type": "object",
+//   "description": "Properties of a breakpoint location returned from the
+//   `breakpointLocations` request.",
+//   "properties": {
+// "line": {
+//   "type": "integer",
+//   "description": "Start line of breakpoint location."
+// },
+// "column": {
+//   "type": "integer",
+//   "description": "The start position of a breakpoint location. Position
+//   is measured in UTF-16 code units and the client capability
+//   `columnsStartAt1` determines whether it is 0- or 1-based."
+// },
+// "endLine": {
+//   "type": "integer",
+//   "description": "The end line of breakpoint location if the location
+//   covers a range."
+// },
+// "endColumn": {
+//   "type": "integer",
+//   "description": "The end position of a breakpoint location (if the
+//   location covers a range). Position is measured in UTF-16 code units 
and
+//   the client capability `columnsStartAt1` determines whether it is 0- or
+//   1-based."
+// }
+//   },
+//   "required": [ "line" ]
+// },
+void request_breakpointLocations(const llvm::json::Object &request) {
+  llvm::json::Object response;
+  FillResponse(request, response);
+  auto *arguments = request.getObject("arguments");
+  auto *source = arguments->getObject("source");
+  std::string path = GetString(source, "path").str();
+  uint64_t start_line = GetUnsigned(arguments, "line", 0);
+  uint64_t start_column = GetUnsigned(arguments, "column", 0);
+  uint64_t end_line = GetUnsigned(arguments, "endLine", start_line);
+  uint64_t end_column =
+  GetUnsigned(arguments, "endColumn", 
std::numeric_limits::max());
+
+  lldb::SBFileSpec file_spec

[Lldb-commits] [lldb] [llvm] [lldb-dap] Support column breakpoints (PR #113787)

2024-11-04 Thread Adrian Vogelsgesang via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Recommend Python 3.8 as the minimum Python version for LLDB (PR #114807)

2024-11-04 Thread David Spickett via lldb-commits

https://github.com/DavidSpickett created 
https://github.com/llvm/llvm-project/pull/114807

See 
https://discourse.llvm.org/t/rfc-lets-document-and-enforce-a-minimum-python-version-for-lldb/82731
 for discussions.

This matches LLVM's requirement to run tests. For LLDB 20 there will be a CMake 
warning telling builders that from LLDB 21 this will be a hard requirement. 
From LLDB 21, it will be an error to try to build with anything <= 3.8.

So there are no code changes in this commit. Once the llvm 20 branch is created 
we can remove some < 3.8 support code.

As always, if you disable Python support you will not get any new warnings or 
errors from this change.

>From 12672234d81cc12625d8832fed4937221d37546e Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 4 Nov 2024 14:41:19 +
Subject: [PATCH] [lldb] Recommend Python 3.8 as the minimum Python version for
 LLDB

See 
https://discourse.llvm.org/t/rfc-lets-document-and-enforce-a-minimum-python-version-for-lldb/82731
for discussions.

This matches LLVM's requirement to run tests. For LLDB 20 there will
be a CMake warning telling builders that from LLDB 21 this will be
a hard requirement. From LLDB 21, it will be an error to try to build
with anything <= 3.8.

So there are no code changes in this commit. Once the llvm 20 branch
is created we can remove some < 3.8 support code.

As always, if you disable Python support you will not get any new
warnings or errors from this change.
---
 lldb/cmake/modules/FindPythonAndSwig.cmake |  7 +
 lldb/docs/resources/build.rst  | 32 +++---
 2 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/lldb/cmake/modules/FindPythonAndSwig.cmake 
b/lldb/cmake/modules/FindPythonAndSwig.cmake
index d62cced0d095e9..2cdd2204ae43cc 100644
--- a/lldb/cmake/modules/FindPythonAndSwig.cmake
+++ b/lldb/cmake/modules/FindPythonAndSwig.cmake
@@ -64,3 +64,10 @@ else()
   Python3_EXECUTABLE
   LLDB_ENABLE_SWIG)
 endif()
+
+set(LLDB_RECOMMENDED_PYTHON "3.8")
+if(Python3_LIBRARIES AND Python3_INCLUDE_DIRS AND Python3_EXECUTABLE AND 
LLDB_ENABLE_SWIG
+   AND "${Python3_VERSION}" VERSION_LESS "${LLDB_RECOMMENDED_PYTHON}")
+  message(WARNING "Using Python ${Python3_VERSION}. ${LLDB_RECOMMENDED_PYTHON} 
"
+  "is recommended and will be required from LLDB 21.")
+endif()
\ No newline at end of file
diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index 33b6a6f79def4b..0ff0a0d7d049e1 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -51,21 +51,21 @@ CMake flag to ``On`` or ``Off`` to force the dependency to 
be enabled or
 disabled. When a dependency is set to ``On`` and can't be found it will cause a
 CMake configuration error.
 
-+---+--+--+
-| Feature   | Description  | 
CMake Flag   |
-+===+==+==+
-| Editline  | Generic line editing, history, Emacs and Vi bindings | 
``LLDB_ENABLE_LIBEDIT``  |
-+---+--+--+
-| Curses| Text user interface  | 
``LLDB_ENABLE_CURSES``   |
-+---+--+--+
-| LZMA  | Lossless data compression| 
``LLDB_ENABLE_LZMA`` |
-+---+--+--+
-| Libxml2   | XML  | 
``LLDB_ENABLE_LIBXML2``  |
-+---+--+--+
-| Python| Python scripting | 
``LLDB_ENABLE_PYTHON``   |
-+---+--+--+
-| Lua   | Lua scripting| 
``LLDB_ENABLE_LUA``  |
-+---+--+--+
++---+--+--+
+| Feature   | Description  
| CMake Flag   |
++===+==+==+
+| Editline  | Generic line editing, history, Emacs and Vi bindings 
| ``LLDB_ENABLE_LIBEDIT``  |
++---+--+--+
+| Curses 

[Lldb-commits] [lldb] [lldb] Recommend Python 3.8 as the minimum Python version for LLDB (PR #114807)

2024-11-04 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Recommend Python 3.8 as the minimum Python version for LLDB (PR #114807)

2024-11-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

See 
https://discourse.llvm.org/t/rfc-lets-document-and-enforce-a-minimum-python-version-for-lldb/82731
 for discussions.

This matches LLVM's requirement to run tests. For LLDB 20 there will be a CMake 
warning telling builders that from LLDB 21 this will be a hard requirement. 
From LLDB 21, it will be an error to try to build with anything <= 3.8.

So there are no code changes in this commit. Once the llvm 20 branch is created 
we can remove some < 3.8 support code.

As always, if you disable Python support you will not get any new warnings or 
errors from this change.

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


2 Files Affected:

- (modified) lldb/cmake/modules/FindPythonAndSwig.cmake (+7) 
- (modified) lldb/docs/resources/build.rst (+16-16) 


``diff
diff --git a/lldb/cmake/modules/FindPythonAndSwig.cmake 
b/lldb/cmake/modules/FindPythonAndSwig.cmake
index d62cced0d095e9..2cdd2204ae43cc 100644
--- a/lldb/cmake/modules/FindPythonAndSwig.cmake
+++ b/lldb/cmake/modules/FindPythonAndSwig.cmake
@@ -64,3 +64,10 @@ else()
   Python3_EXECUTABLE
   LLDB_ENABLE_SWIG)
 endif()
+
+set(LLDB_RECOMMENDED_PYTHON "3.8")
+if(Python3_LIBRARIES AND Python3_INCLUDE_DIRS AND Python3_EXECUTABLE AND 
LLDB_ENABLE_SWIG
+   AND "${Python3_VERSION}" VERSION_LESS "${LLDB_RECOMMENDED_PYTHON}")
+  message(WARNING "Using Python ${Python3_VERSION}. ${LLDB_RECOMMENDED_PYTHON} 
"
+  "is recommended and will be required from LLDB 21.")
+endif()
\ No newline at end of file
diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index 33b6a6f79def4b..0ff0a0d7d049e1 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -51,21 +51,21 @@ CMake flag to ``On`` or ``Off`` to force the dependency to 
be enabled or
 disabled. When a dependency is set to ``On`` and can't be found it will cause a
 CMake configuration error.
 
-+---+--+--+
-| Feature   | Description  | 
CMake Flag   |
-+===+==+==+
-| Editline  | Generic line editing, history, Emacs and Vi bindings | 
``LLDB_ENABLE_LIBEDIT``  |
-+---+--+--+
-| Curses| Text user interface  | 
``LLDB_ENABLE_CURSES``   |
-+---+--+--+
-| LZMA  | Lossless data compression| 
``LLDB_ENABLE_LZMA`` |
-+---+--+--+
-| Libxml2   | XML  | 
``LLDB_ENABLE_LIBXML2``  |
-+---+--+--+
-| Python| Python scripting | 
``LLDB_ENABLE_PYTHON``   |
-+---+--+--+
-| Lua   | Lua scripting| 
``LLDB_ENABLE_LUA``  |
-+---+--+--+
++---+--+--+
+| Feature   | Description  
| CMake Flag   |
++===+==+==+
+| Editline  | Generic line editing, history, Emacs and Vi bindings 
| ``LLDB_ENABLE_LIBEDIT``  |
++---+--+--+
+| Curses| Text user interface  
| ``LLDB_ENABLE_CURSES``   |
++---+--+--+
+| LZMA  | Lossless data compression
| ``LLDB_ENABLE_LZMA`` |
++---+--+--+
+| Libxml2   | XML  
| ``LLDB_ENABLE_LIBXML2``  |
++---+--+--+
+| Python| Python scripting. >= 3.0 is required, >= 3.8 is 
recommended. |

[Lldb-commits] [clang] [clang-tools-extra] [flang] [lldb] [llvm] [openmp] [pstl] Finally formalise our defacto line-ending policy (PR #86318)

2024-11-04 Thread Aaron Ballman via lldb-commits

AaronBallman wrote:

> @AaronBallman you said this has happened before, but I don't see this in 
> history. Can you link to the commit to which you're referring?
> 
> I only see one other commit 
> ([9783f28](https://github.com/llvm/llvm-project/commit/9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7))
>  that touches the root `.gitattributes`

https://reviews.llvm.org/D124563 and https://reviews.llvm.org/D124606 where 
there was a lot of back and forth on the changes after they landed, but I may 
have missed some discussions too.

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


[Lldb-commits] [lldb] Fix pointer to reference type (PR #113596)

2024-11-04 Thread Pavel Labath via lldb-commits

labath wrote:

Thanks for your understanding. Here's a revert PR 
(https://github.com/llvm/llvm-project/pull/114831). I'll submit it after the CI 
runs. Would you like to create an RFC thread to continue this discussion?

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


[Lldb-commits] [lldb] Revert "Fix pointer to reference type (#113596)" (PR #114831)

2024-11-04 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

This reverts commit 25909b811a7ddc983d042b15cb54ec271a673d63 due to unresolved 
questions about the behavior of "frame var" and ValueObject in the presence of 
references (see the original patch for discussion).

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


3 Files Affected:

- (modified) lldb/source/ValueObject/ValueObject.cpp (-9) 
- (modified) 
lldb/test/API/lang/cpp/dereferencing_references/TestCPPDereferencingReferences.py
 (-21) 
- (modified) lldb/test/API/lang/cpp/dereferencing_references/main.cpp (-2) 


``diff
diff --git a/lldb/source/ValueObject/ValueObject.cpp 
b/lldb/source/ValueObject/ValueObject.cpp
index aca43175d12fac..4006f6e6fd0a5e 100644
--- a/lldb/source/ValueObject/ValueObject.cpp
+++ b/lldb/source/ValueObject/ValueObject.cpp
@@ -2907,15 +2907,6 @@ ValueObjectSP ValueObject::AddressOf(Status &error) {
 
   AddressType address_type = eAddressTypeInvalid;
   const bool scalar_is_load_address = false;
-
-  // For reference type we need to get the address of the object that
-  // it refers to.
-  if (GetCompilerType().IsReferenceType()) {
-ValueObjectSP deref_obj = Dereference(error);
-if (error.Fail() || !deref_obj)
-  return ValueObjectSP();
-return deref_obj->AddressOf(error);
-  }
   addr_t addr = GetAddressOf(scalar_is_load_address, &address_type);
   error.Clear();
   if (addr != LLDB_INVALID_ADDRESS && address_type != eAddressTypeHost) {
diff --git 
a/lldb/test/API/lang/cpp/dereferencing_references/TestCPPDereferencingReferences.py
 
b/lldb/test/API/lang/cpp/dereferencing_references/TestCPPDereferencingReferences.py
index 1374d4e1ec67ab..938fb1a6edf32c 100644
--- 
a/lldb/test/API/lang/cpp/dereferencing_references/TestCPPDereferencingReferences.py
+++ 
b/lldb/test/API/lang/cpp/dereferencing_references/TestCPPDereferencingReferences.py
@@ -25,24 +25,3 @@ def test(self):
 # Typedef to a reference should dereference to the underlying type.
 td_val = self.expect_var_path("td_to_ref_type", type="td_int_ref")
 self.assertEqual(td_val.Dereference().GetType().GetName(), "int")
-
-def test_take_address_of_reference(self):
-"""Tests taking address of lvalue/rvalue references in lldb works 
correctly."""
-self.build()
-lldbutil.run_to_source_breakpoint(
-self, "// break here", lldb.SBFileSpec("main.cpp")
-)
-
-plref_val_from_code = self.expect_var_path("pl_ref", type="TTT *")
-plref_val_from_expr_path = self.expect_var_path("&l_ref", type="TTT *")
-self.assertEqual(
-plref_val_from_code.GetValueAsAddress(),
-plref_val_from_expr_path.GetValueAsAddress(),
-)
-
-prref_val_from_code = self.expect_var_path("pr_ref", type="TTT *")
-prref_val_from_expr_path = self.expect_var_path("&r_ref", type="TTT *")
-self.assertEqual(
-prref_val_from_code.GetValueAsAddress(),
-prref_val_from_expr_path.GetValueAsAddress(),
-)
diff --git a/lldb/test/API/lang/cpp/dereferencing_references/main.cpp 
b/lldb/test/API/lang/cpp/dereferencing_references/main.cpp
index 4ddffd167ddeed..b64978a9029f81 100644
--- a/lldb/test/API/lang/cpp/dereferencing_references/main.cpp
+++ b/lldb/test/API/lang/cpp/dereferencing_references/main.cpp
@@ -9,7 +9,5 @@ int main() {
   // typedef of a reference
   td_int_ref td_to_ref_type = i;
 
-  TTT *pl_ref = &l_ref;
-  TTT *pr_ref = &r_ref;
   return l_ref; // break here
 }

``




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


[Lldb-commits] [lldb] [lldb][breakpoint] Grey out disabled breakpoints (PR #91404)

2024-11-04 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,32 @@
+"""
+Test that disabling breakpoints and viewing them in a list uses the correct 
ANSI color settings when colors are enabled and disabled.
+"""
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+import re
+import io
+
+
+class DisabledBreakpointsTest(PExpectTest):
+@add_test_categories(["pexpect"])
+def test_disabling_breakpoints_with_color(self):
+"""Test that disabling a breakpoint and viewing the breakpoints list 
uses the specified ANSI color prefix."""
+import pexpect
+
+self.child = pexpect.spawn("expect", encoding="utf-8")
+
+ansi_red_color_code = "\x1b[31m"
+
+self.launch(use_colors=True, dimensions=(100, 100))
+self.child.sendline(

labath wrote:

Any reason you can't use self.expect instead?

Even if you don't pass it any expectations to it, that function will at least 
check for the lldb prompt, which means it will wait for lldb to process the 
previous command before you feed it the next one. That makes the test much more 
deterministic and reliable.

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


[Lldb-commits] [lldb] [lldb][breakpoint] Grey out disabled breakpoints (PR #91404)

2024-11-04 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,32 @@
+"""
+Test that disabling breakpoints and viewing them in a list uses the correct 
ANSI color settings when colors are enabled and disabled.
+"""
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+import re
+import io
+
+
+class DisabledBreakpointsTest(PExpectTest):
+@add_test_categories(["pexpect"])
+def test_disabling_breakpoints_with_color(self):
+"""Test that disabling a breakpoint and viewing the breakpoints list 
uses the specified ANSI color prefix."""
+import pexpect
+
+self.child = pexpect.spawn("expect", encoding="utf-8")
+

labath wrote:

???

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


[Lldb-commits] [lldb] [lldb][test] Skip libc++ tests if it is linked statically (PR #113935)

2024-11-04 Thread Pavel Labath via lldb-commits

labath wrote:

> Or just change the function we're calling from `at` to something that doesn't 
> pull in the symbol from the dylib? That should still provide us with coverage 
> of calling functions from the `std` module

That might work too (depending on how good we/clang are at not importing the 
unused parts of the libc++ module).

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


[Lldb-commits] [lldb] [lldb] Lookup static const members in FindGlobalVariables (PR #111859)

2024-11-04 Thread Pavel Labath via lldb-commits


@@ -362,6 +369,23 @@ void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
 set.namespaces.Insert(ConstString(name), ref);
   break;
 
+case DW_TAG_member: {
+  // In DWARF 4 and earlier `static const` members of a struct, a class or 
a
+  // union have an entry tag `DW_TAG_member`, and are also tagged as
+  // `DW_AT_external` and `DW_AT_declaration`, but otherwise follow the
+  // same rules as `DW_TAG_variable`.
+  if (unit.GetVersion() >= 5)
+break;
+  bool parent_is_class_type = false;
+  if (auto parent = die.GetParent()) {
+parent_is_class_type = parent->Tag() == DW_TAG_structure_type ||
+   parent->Tag() == DW_TAG_class_type ||
+   parent->Tag() == DW_TAG_union_type;
+  }

labath wrote:

```suggestion
  bool parent_is_class_type = false;
  if (auto parent = die.GetParent())
parent_is_class_type = DWARFDIE(&unit, parent).IsStructUnionOrClass();
```

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


[Lldb-commits] [lldb] [lldb] Lookup static const members in FindGlobalVariables (PR #111859)

2024-11-04 Thread Pavel Labath via lldb-commits


@@ -3490,7 +3490,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const 
SymbolContext &sc,
   ModuleSP module = GetObjectFile()->GetModule();
 
   if (tag != DW_TAG_variable && tag != DW_TAG_constant &&
-  (tag != DW_TAG_formal_parameter || !sc.function))
+  tag != DW_TAG_member && (tag != DW_TAG_formal_parameter || !sc.function))

labath wrote:

I don't think that should be an assert unless some piece of code (where?) 
alredy makes sure that these kinds of DIEs don't make their way here. Debug 
info can come from all kinds of compilers (including those from the past and 
the future), so we shouldn't be crashing just because we've ran into debug info 
(aka "user input") that we don't understand. Logging something or reporting a 
warning might be more appropriate.

Checking for this member when detecting a static const member might be okay, 
but it doesn't really count as the check I mention above, since it only works 
for the manual index. The other indexes come straight from the compiler (past, 
future, etc.) so they can't be relied upon in the same way. For this reason 
(and because we want to make the indexing step as fast as possible), I'd put 
the check into the indexing step only if it's necessary to properly detect 
static members.

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


[Lldb-commits] [lldb] [lldb] Lookup static const members in FindGlobalVariables (PR #111859)

2024-11-04 Thread Pavel Labath via lldb-commits


@@ -362,6 +369,23 @@ void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
 set.namespaces.Insert(ConstString(name), ref);
   break;
 
+case DW_TAG_member: {
+  // In DWARF 4 and earlier `static const` members of a struct, a class or 
a
+  // union have an entry tag `DW_TAG_member`, and are also tagged as
+  // `DW_AT_external` and `DW_AT_declaration`, but otherwise follow the
+  // same rules as `DW_TAG_variable`.
+  if (unit.GetVersion() >= 5)
+break;
+  bool parent_is_class_type = false;
+  if (auto parent = die.GetParent()) {
+parent_is_class_type = parent->Tag() == DW_TAG_structure_type ||
+   parent->Tag() == DW_TAG_class_type ||
+   parent->Tag() == DW_TAG_union_type;
+  }
+  if (!parent_is_class_type || !is_external || !is_declaration)

labath wrote:

Good finding. I think it would be good to match whatever that code does. 
(making it a single function for it would be somewhat tricky, as the code here 
needs to be very fast, so we don't want to have the helper function do another 
lookup for the attributes and stuff).

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


[Lldb-commits] [lldb] [lldb] Lookup static const members in FindGlobalVariables (PR #111859)

2024-11-04 Thread Pavel Labath via lldb-commits


@@ -362,6 +369,23 @@ void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
 set.namespaces.Insert(ConstString(name), ref);
   break;
 
+case DW_TAG_member: {
+  // In DWARF 4 and earlier `static const` members of a struct, a class or 
a
+  // union have an entry tag `DW_TAG_member`, and are also tagged as
+  // `DW_AT_external` and `DW_AT_declaration`, but otherwise follow the
+  // same rules as `DW_TAG_variable`.
+  if (unit.GetVersion() >= 5)
+break;

labath wrote:

Let's put this into the first switch statement (something like `case 
DW_TAG_member: if (unit.GetVersion() >= 5) continue; else break;`), so that we 
avoid parsing the attributes when we know we're not going to use them.

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


[Lldb-commits] [lldb] [lldb][breakpoint] Grey out disabled breakpoints (PR #91404)

2024-11-04 Thread Pavel Labath via lldb-commits


@@ -77,6 +78,15 @@ void SBStream::Printf(const char *format, ...) {
   va_end(args);
 }
 
+bool SBStream::HasColor() {
+  return m_opaque_up->AsRawOstream().colors_enabled();
+}
+
+void SBStream::FormatAnsiTerminalCodes(llvm::StringRef format) {
+  if (HasColor())
+Printf("%s", ansi::FormatAnsiTerminalCodes(format).c_str());

labath wrote:

```suggestion
m_opaque_up->PutCString(ansi::FormatAnsiTerminalCodes(format));
```

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


[Lldb-commits] [lldb] Fix a thinko in the CallSite handling code: (PR #114896)

2024-11-04 Thread via lldb-commits

https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/114896

>From 38c7625fc7899f91190711818c144f27a39423c0 Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Mon, 4 Nov 2024 15:56:26 -0800
Subject: [PATCH 1/2] Fix a thinko in the CallSite handling code:

I have to check for the sc list size being changed by the call-site
search, not just that it had more than one element.

Added a test for multiple CU's with the same name in a given module,
which would have caught this mistake.
---
 lldb/source/Symbol/CompileUnit.cpp| 10 ---
 .../breakpoint/same_cu_name/Makefile  | 19 
 .../TestFileBreakpoinsSameCUName.py   | 29 +++
 .../breakpoint/same_cu_name/common.cpp| 12 
 .../breakpoint/same_cu_name/main.cpp  | 25 
 5 files changed, 91 insertions(+), 4 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/breakpoint/same_cu_name/Makefile
 create mode 100644 
lldb/test/API/functionalities/breakpoint/same_cu_name/TestFileBreakpoinsSameCUName.py
 create mode 100644 
lldb/test/API/functionalities/breakpoint/same_cu_name/common.cpp
 create mode 100644 
lldb/test/API/functionalities/breakpoint/same_cu_name/main.cpp

diff --git a/lldb/source/Symbol/CompileUnit.cpp 
b/lldb/source/Symbol/CompileUnit.cpp
index 73389b2e8479b3..d7df6ee1f221b3 100644
--- a/lldb/source/Symbol/CompileUnit.cpp
+++ b/lldb/source/Symbol/CompileUnit.cpp
@@ -326,16 +326,18 @@ void CompileUnit::ResolveSymbolContext(
   // the function containing the PC of the line table match.  That way we can
   // limit the call site search to that function.
   // We will miss functions that ONLY exist as a call site entry.
-
+  
   if (line_entry.IsValid() &&
-  (line_entry.line != line || line_entry.column != column_num) &&
-  resolve_scope & eSymbolContextLineEntry && check_inlines) {
+  (line_entry.line != line || (column_num != 0 && line_entry.column != 
column_num))
+  && (resolve_scope & eSymbolContextLineEntry) && check_inlines) {
 // We don't move lines over function boundaries, so the address in the
 // line entry will be the in function that contained the line that might
 // be a CallSite, and we can just iterate over that function to find any
 // inline records, and dig up their call sites.
 Address start_addr = line_entry.range.GetBaseAddress();
 Function *function = start_addr.CalculateSymbolContextFunction();
+// Record the size of the list to see if we added to it:
+size_t old_sc_list_size = sc_list.GetSize();
 
 Declaration sought_decl(file_spec, line, column_num);
 // We use this recursive function to descend the block structure looking
@@ -417,7 +419,7 @@ void CompileUnit::ResolveSymbolContext(
 // FIXME: Should I also do this for "call site line exists between the
 // given line number and the later line we found in the line table"?  
That's
 // a closer approximation to our general sliding algorithm.
-if (sc_list.GetSize())
+if (sc_list.GetSize() > old_sc_list_size)
   return;
   }
 
diff --git a/lldb/test/API/functionalities/breakpoint/same_cu_name/Makefile 
b/lldb/test/API/functionalities/breakpoint/same_cu_name/Makefile
new file mode 100644
index 00..4bfdb15e777d99
--- /dev/null
+++ b/lldb/test/API/functionalities/breakpoint/same_cu_name/Makefile
@@ -0,0 +1,19 @@
+CXX_SOURCES := main.cpp
+LD_EXTRAS := ns1.o ns2.o ns3.o ns4.o
+
+a.out: main.o ns1.o ns2.o ns3.o ns4.o
+
+ns1.o: common.cpp
+   $(CC) -g -c -DNAMESPACE=ns1 -o $@ $<
+
+ns2.o: common.cpp
+   $(CC) -g -c -DNAMESPACE=ns2 -o $@ $<
+
+ns3.o: common.cpp
+   $(CC) -g -c -DNAMESPACE=ns3 -o $@ $<
+
+ns4.o: common.cpp
+   $(CC) -g -c -DNAMESPACE=ns4 -o $@ $<
+
+
+include Makefile.rules
diff --git 
a/lldb/test/API/functionalities/breakpoint/same_cu_name/TestFileBreakpoinsSameCUName.py
 
b/lldb/test/API/functionalities/breakpoint/same_cu_name/TestFileBreakpoinsSameCUName.py
new file mode 100644
index 00..74524685b55771
--- /dev/null
+++ 
b/lldb/test/API/functionalities/breakpoint/same_cu_name/TestFileBreakpoinsSameCUName.py
@@ -0,0 +1,29 @@
+"""
+Test setting a breakpoint by file and line when many instances of the
+same file name exist in the CU list.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestBreakpointSameCU(TestBase):
+def test_breakpoint_same_cu(self):
+self.build()
+target = self.createTestTarget()
+
+# Break both on the line before the code:
+comment_line = line_number("common.cpp", "// A comment here")
+self.assertNotEqual(comment_line, 0, "line_number worked")
+bkpt = target.BreakpointCreateByLocation("common.cpp", comment_line)
+self.assertEqual(bkpt.GetNumLocations(), 4, "Got the right number of 
breakpoints")
+
+# And break on the code, both should work:
+  

[Lldb-commits] [lldb] More refinement of call site handling in stepping. (PR #114628)

2024-11-04 Thread via lldb-commits

https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/114628

>From 042ac07ed67a5465aaf5c2dc8c4396adf5da2948 Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Fri, 1 Nov 2024 17:23:12 -0700
Subject: [PATCH 1/3] More refinement of call site handling in stepping.

When you set a "next branch breakpoint" and run to it while
stepping, you have to claim the stop at that breakpoint to be
the top of the inlined call stack, or you will seem to "step in"
and then plans might try to step back out again.

This records the PrefferedLineEntry for next branch breakpoints and
adds a test to make sure this works.
---
 lldb/source/Target/ThreadPlanStepRange.cpp| 42 +--
 .../inline-stepping/TestInlineStepping.py | 20 -
 2 files changed, 58 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Target/ThreadPlanStepRange.cpp 
b/lldb/source/Target/ThreadPlanStepRange.cpp
index 3c825058b8c375..e53b189d49be44 100644
--- a/lldb/source/Target/ThreadPlanStepRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepRange.cpp
@@ -379,10 +379,9 @@ bool ThreadPlanStepRange::SetNextBranchBreakpoint() {
 !m_next_branch_bp_sp->HasResolvedLocations())
   m_could_not_resolve_hw_bp = true;
 
+BreakpointLocationSP bp_loc = 
m_next_branch_bp_sp->GetLocationAtIndex(0);
 if (log) {
   lldb::break_id_t bp_site_id = LLDB_INVALID_BREAK_ID;
-  BreakpointLocationSP bp_loc =
-  m_next_branch_bp_sp->GetLocationAtIndex(0);
   if (bp_loc) {
 BreakpointSiteSP bp_site = bp_loc->GetBreakpointSite();
 if (bp_site) {
@@ -395,7 +394,44 @@ bool ThreadPlanStepRange::SetNextBranchBreakpoint() {
 m_next_branch_bp_sp->GetID(), bp_site_id,
 run_to_address.GetLoadAddress(&m_process.GetTarget()));
 }
-
+// The "next branch breakpoint might land on an virtual inlined call
+// stack.  If that's true, we should always stop at the top of the
+// inlined call stack.  Only virtual steps should walk deeper into the
+// inlined call stack.
+Block *block = run_to_address.CalculateSymbolContextBlock();
+if (bp_loc && block) {
+  LineEntry top_most_line_entry;
+  lldb::addr_t run_to_addr = run_to_address.GetFileAddress();
+  for (Block *inlined_parent = block->GetContainingInlinedBlock(); 
inlined_parent;
+  inlined_parent = inlined_parent->GetInlinedParent()) {
+AddressRange range;
+if (!inlined_parent->GetRangeContainingAddress(run_to_address, 
range))
+   break;
+Address range_start_address = range.GetBaseAddress();
+// Only compare addresses here, we may have different symbol
+// contexts (for virtual inlined stacks), but we just want to know
+// that they are all at the same address.
+if (range_start_address.GetFileAddress() != run_to_addr) 
+  break;
+const InlineFunctionInfo *inline_info = 
inlined_parent->GetInlinedFunctionInfo();
+if (!inline_info)
+  break;
+const Declaration &call_site = inline_info->GetCallSite();
+top_most_line_entry.line = call_site.GetLine();
+top_most_line_entry.column = call_site.GetColumn();
+FileSpec call_site_file_spec = call_site.GetFile();
+top_most_line_entry.original_file_sp.reset(new 
SupportFile(call_site_file_spec));
+top_most_line_entry.range = range;
+top_most_line_entry.file_sp.reset();
+
top_most_line_entry.ApplyFileMappings(GetThread().CalculateTarget());
+if (!top_most_line_entry.file_sp)
+  top_most_line_entry.file_sp = 
top_most_line_entry.original_file_sp;
+  }
+  if (top_most_line_entry.IsValid()) {
+LLDB_LOG(log, "Setting preferred line entry: {0}:{1}", 
top_most_line_entry.GetFile(), top_most_line_entry.line);
+bp_loc->SetPreferredLineEntry(top_most_line_entry);
+  }
+}
 m_next_branch_bp_sp->SetThreadID(m_tid);
 m_next_branch_bp_sp->SetBreakpointKind("next-branch-location");
 
diff --git 
a/lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py 
b/lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py
index 4e2d908e63b81c..b43bc71243f259 100644
--- a/lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py
+++ b/lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py
@@ -291,7 +291,7 @@ def inline_stepping_step_over(self):
 break_1_in_main = target.BreakpointCreateBySourceRegex(
 "// At second call of caller_ref_1 in main.", self.main_source_spec
 )
-self.assertTrue(break_1_in_main, VALID_BREAKPOINT)
+self.assertGreater(break_1_in_main.GetNumLocations(), 0, 
VALID_BREAKPOINT)
 
 # Now launch the process, and do not stop a

[Lldb-commits] [lldb] More refinement of call site handling in stepping. (PR #114628)

2024-11-04 Thread via lldb-commits

https://github.com/jimingham updated 
https://github.com/llvm/llvm-project/pull/114628

>From 042ac07ed67a5465aaf5c2dc8c4396adf5da2948 Mon Sep 17 00:00:00 2001
From: Jim Ingham 
Date: Fri, 1 Nov 2024 17:23:12 -0700
Subject: [PATCH 1/4] More refinement of call site handling in stepping.

When you set a "next branch breakpoint" and run to it while
stepping, you have to claim the stop at that breakpoint to be
the top of the inlined call stack, or you will seem to "step in"
and then plans might try to step back out again.

This records the PrefferedLineEntry for next branch breakpoints and
adds a test to make sure this works.
---
 lldb/source/Target/ThreadPlanStepRange.cpp| 42 +--
 .../inline-stepping/TestInlineStepping.py | 20 -
 2 files changed, 58 insertions(+), 4 deletions(-)

diff --git a/lldb/source/Target/ThreadPlanStepRange.cpp 
b/lldb/source/Target/ThreadPlanStepRange.cpp
index 3c825058b8c375..e53b189d49be44 100644
--- a/lldb/source/Target/ThreadPlanStepRange.cpp
+++ b/lldb/source/Target/ThreadPlanStepRange.cpp
@@ -379,10 +379,9 @@ bool ThreadPlanStepRange::SetNextBranchBreakpoint() {
 !m_next_branch_bp_sp->HasResolvedLocations())
   m_could_not_resolve_hw_bp = true;
 
+BreakpointLocationSP bp_loc = 
m_next_branch_bp_sp->GetLocationAtIndex(0);
 if (log) {
   lldb::break_id_t bp_site_id = LLDB_INVALID_BREAK_ID;
-  BreakpointLocationSP bp_loc =
-  m_next_branch_bp_sp->GetLocationAtIndex(0);
   if (bp_loc) {
 BreakpointSiteSP bp_site = bp_loc->GetBreakpointSite();
 if (bp_site) {
@@ -395,7 +394,44 @@ bool ThreadPlanStepRange::SetNextBranchBreakpoint() {
 m_next_branch_bp_sp->GetID(), bp_site_id,
 run_to_address.GetLoadAddress(&m_process.GetTarget()));
 }
-
+// The "next branch breakpoint might land on an virtual inlined call
+// stack.  If that's true, we should always stop at the top of the
+// inlined call stack.  Only virtual steps should walk deeper into the
+// inlined call stack.
+Block *block = run_to_address.CalculateSymbolContextBlock();
+if (bp_loc && block) {
+  LineEntry top_most_line_entry;
+  lldb::addr_t run_to_addr = run_to_address.GetFileAddress();
+  for (Block *inlined_parent = block->GetContainingInlinedBlock(); 
inlined_parent;
+  inlined_parent = inlined_parent->GetInlinedParent()) {
+AddressRange range;
+if (!inlined_parent->GetRangeContainingAddress(run_to_address, 
range))
+   break;
+Address range_start_address = range.GetBaseAddress();
+// Only compare addresses here, we may have different symbol
+// contexts (for virtual inlined stacks), but we just want to know
+// that they are all at the same address.
+if (range_start_address.GetFileAddress() != run_to_addr) 
+  break;
+const InlineFunctionInfo *inline_info = 
inlined_parent->GetInlinedFunctionInfo();
+if (!inline_info)
+  break;
+const Declaration &call_site = inline_info->GetCallSite();
+top_most_line_entry.line = call_site.GetLine();
+top_most_line_entry.column = call_site.GetColumn();
+FileSpec call_site_file_spec = call_site.GetFile();
+top_most_line_entry.original_file_sp.reset(new 
SupportFile(call_site_file_spec));
+top_most_line_entry.range = range;
+top_most_line_entry.file_sp.reset();
+
top_most_line_entry.ApplyFileMappings(GetThread().CalculateTarget());
+if (!top_most_line_entry.file_sp)
+  top_most_line_entry.file_sp = 
top_most_line_entry.original_file_sp;
+  }
+  if (top_most_line_entry.IsValid()) {
+LLDB_LOG(log, "Setting preferred line entry: {0}:{1}", 
top_most_line_entry.GetFile(), top_most_line_entry.line);
+bp_loc->SetPreferredLineEntry(top_most_line_entry);
+  }
+}
 m_next_branch_bp_sp->SetThreadID(m_tid);
 m_next_branch_bp_sp->SetBreakpointKind("next-branch-location");
 
diff --git 
a/lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py 
b/lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py
index 4e2d908e63b81c..b43bc71243f259 100644
--- a/lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py
+++ b/lldb/test/API/functionalities/inline-stepping/TestInlineStepping.py
@@ -291,7 +291,7 @@ def inline_stepping_step_over(self):
 break_1_in_main = target.BreakpointCreateBySourceRegex(
 "// At second call of caller_ref_1 in main.", self.main_source_spec
 )
-self.assertTrue(break_1_in_main, VALID_BREAKPOINT)
+self.assertGreater(break_1_in_main.GetNumLocations(), 0, 
VALID_BREAKPOINT)
 
 # Now launch the process, and do not stop a

[Lldb-commits] [lldb] Fix call site breakpoint patch (PR #114158)

2024-11-04 Thread Jorge Gorbe Moya via lldb-commits

slackito wrote:

Thanks for the quick response, Jim!

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


[Lldb-commits] [lldb] a57296a - [lldb] Create dependent modules in parallel (#114507)

2024-11-04 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2024-11-04T13:32:22-08:00
New Revision: a57296ad411a75c1376458f6b09cb75128c6e785

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

LOG: [lldb] Create dependent modules in parallel (#114507)

Create dependent modules in parallel in Target::SetExecutableModule.
This change was inspired by #110646 which takes the same approach when
attaching. Jason suggested we could use the same approach when you
create a target in LLDB.

I used Slack for benchmarking, which loads 902 images.

```
Benchmark 1: ./bin/lldb /Applications/Slack.app/Contents/MacOS/Slack
  Time (mean ± σ):  1.225 s ±  0.003 s[User: 3.977 s, System: 1.521 s]
  Range (min … max):1.220 s …  1.229 s10 runs

Benchmark 2: ./bin/lldb /Applications/Slack.app/Contents/MacOS/Slack
  Time (mean ± σ):  3.253 s ±  0.037 s[User: 3.013 s, System: 0.248 s]
  Range (min … max):3.211 s …  3.310 s10 runs
```

We see about a 2x speedup, which matches what Jason saw for the attach
scenario. I also ran this under TSan to confirm this doesn't introduce
any races or deadlocks.

Added: 


Modified: 
lldb/source/Target/Target.cpp

Removed: 




diff  --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 199efae8a728cc..8cd3fa8af6bae1 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -68,6 +68,7 @@
 
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SetVector.h"
+#include "llvm/Support/ThreadPool.h"
 
 #include 
 #include 
@@ -1575,7 +1576,6 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
m_arch.GetSpec().GetTriple().getTriple());
 }
 
-FileSpecList dependent_files;
 ObjectFile *executable_objfile = executable_sp->GetObjectFile();
 bool load_dependents = true;
 switch (load_dependent_files) {
@@ -1591,10 +1591,14 @@ void Target::SetExecutableModule(ModuleSP 
&executable_sp,
 }
 
 if (executable_objfile && load_dependents) {
+  // FileSpecList is not thread safe and needs to be synchronized.
+  FileSpecList dependent_files;
+  std::mutex dependent_files_mutex;
+
+  // ModuleList is thread safe.
   ModuleList added_modules;
-  executable_objfile->GetDependentModules(dependent_files);
-  for (uint32_t i = 0; i < dependent_files.GetSize(); i++) {
-FileSpec dependent_file_spec(dependent_files.GetFileSpecAtIndex(i));
+
+  auto GetDependentModules = [&](FileSpec dependent_file_spec) {
 FileSpec platform_dependent_file_spec;
 if (m_platform_sp)
   m_platform_sp->GetFileWithUUID(dependent_file_spec, nullptr,
@@ -1608,9 +1612,48 @@ void Target::SetExecutableModule(ModuleSP &executable_sp,
 if (image_module_sp) {
   added_modules.AppendIfNeeded(image_module_sp, false);
   ObjectFile *objfile = image_module_sp->GetObjectFile();
-  if (objfile)
-objfile->GetDependentModules(dependent_files);
+  if (objfile) {
+// Create a local copy of the dependent file list so we don't have
+// to lock for the whole duration of GetDependentModules.
+FileSpecList dependent_files_copy;
+{
+  std::lock_guard guard(dependent_files_mutex);
+  dependent_files_copy = dependent_files;
+}
+
+// Remember the size of the local copy so we can append only the
+// modules that have been added by GetDependentModules.
+const size_t previous_dependent_files =
+dependent_files_copy.GetSize();
+
+objfile->GetDependentModules(dependent_files_copy);
+
+{
+  std::lock_guard guard(dependent_files_mutex);
+  for (size_t i = previous_dependent_files;
+   i < dependent_files_copy.GetSize(); ++i)
+dependent_files.AppendIfUnique(
+dependent_files_copy.GetFileSpecAtIndex(i));
+}
+  }
+}
+  };
+
+  executable_objfile->GetDependentModules(dependent_files);
+
+  llvm::ThreadPoolTaskGroup task_group(Debugger::GetThreadPool());
+  for (uint32_t i = 0; i < dependent_files.GetSize(); i++) {
+// Process all currently known dependencies in parallel in the 
innermost
+// loop. This may create newly discovered dependencies to be appended 
to
+// dependent_files. We'll deal with these files during the next
+// iteration of the outermost loop.
+{
+  std::lock_guard guard(dependent_files_mutex);
+  for (; i < dependent_files.GetSize(); i++)
+task_group.async(GetDependentModules,
+ dependent_files.GetFileSpecAtIndex(i));
 }
+task_group.wait();

[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap to support running in a server mode, allowing multiple connections. (PR #114881)

2024-11-04 Thread Adrian Vogelsgesang via lldb-commits


@@ -9,21 +9,28 @@
 #ifndef LLDB_TOOLS_LLDB_DAP_BREAKPOINTBASE_H
 #define LLDB_TOOLS_LLDB_DAP_BREAKPOINTBASE_H
 
-#include "llvm/Support/JSON.h"
 #include 
 
+#include "llvm/Support/JSON.h"
+
+#include "DAPForward.h"
+
 namespace lldb_dap {
 
 struct BreakpointBase {
+  // Associated DAP session.
+  DAP *dap;
 
   // An optional expression for conditional breakpoints.
   std::string condition;
   // An optional expression that controls how many hits of the breakpoint are
   // ignored. The backend is expected to interpret the expression as needed
   std::string hitCondition;
 
+  BreakpointBase(DAP *d) : dap(d) {}
+  BreakpointBase(DAP *d, const llvm::json::Object &obj);

vogelsgesang wrote:

afaik, those are not allowed to be nullptrs, are they?

```suggestion
  BreakpointBase(DAP &d) : dap(d) {}
  BreakpointBase(DAP &d, const llvm::json::Object &obj);
```

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap to support running in a server mode, allowing multiple connections. (PR #114881)

2024-11-04 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang commented:

partial review

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap to support running in a server mode, allowing multiple connections. (PR #114881)

2024-11-04 Thread Adrian Vogelsgesang via lldb-commits


@@ -12,15 +12,19 @@
 
 namespace lldb_dap {
 
-SourceBreakpoint::SourceBreakpoint(const llvm::json::Object &obj)
-: Breakpoint(obj), logMessage(std::string(GetString(obj, "logMessage"))),
+SourceBreakpoint::SourceBreakpoint(DAP *dap, const llvm::json::Object &obj)
+: Breakpoint(dap, obj),
+  logMessage(std::string(GetString(obj, "logMessage"))),
   line(GetUnsigned(obj, "line", 0)), column(GetUnsigned(obj, "column", 0)) 
{
 }
 
 void SourceBreakpoint::SetBreakpoint(const llvm::StringRef source_path) {
+  if (!dap)

vogelsgesang wrote:

when would that happen?

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap to support running in a server mode, allowing multiple connections. (PR #114881)

2024-11-04 Thread Adrian Vogelsgesang via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap to support running in a server mode, allowing multiple connections. (PR #114881)

2024-11-04 Thread Adrian Vogelsgesang via lldb-commits


@@ -9,21 +9,28 @@
 #ifndef LLDB_TOOLS_LLDB_DAP_BREAKPOINTBASE_H
 #define LLDB_TOOLS_LLDB_DAP_BREAKPOINTBASE_H
 
-#include "llvm/Support/JSON.h"
 #include 
 
+#include "llvm/Support/JSON.h"
+
+#include "DAPForward.h"
+
 namespace lldb_dap {
 
 struct BreakpointBase {
+  // Associated DAP session.
+  DAP *dap;

vogelsgesang wrote:

is this allowed to be a nullptr?
Do we use `std::reference_wrapper` in LLVM / lldb?

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


[Lldb-commits] [lldb] Fix call site breakpoint patch (PR #114158)

2024-11-04 Thread via lldb-commits

jimingham wrote:

There were two issues here, one very minor, and then one that mattered...  This 
was a little thinko, I forgot that we build into the same SymbolContextList 
over all the CU iterations, so I needed to check "did I add to the SC list" not 
"is there anything in the SC list" to see if looking for a call site found 
anything:

diff --git a/lldb/source/Symbol/CompileUnit.cpp 
b/lldb/source/Symbol/CompileUnit.cpp
index 73389b2e8479..d7df6ee1f221 100644
--- a/lldb/source/Symbol/CompileUnit.cpp
+++ b/lldb/source/Symbol/CompileUnit.cpp
@@ -326,16 +326,18 @@ void CompileUnit::ResolveSymbolContext(
   // the function containing the PC of the line table match.  That way we can
   // limit the call site search to that function.
   // We will miss functions that ONLY exist as a call site entry.
-
+  
   if (line_entry.IsValid() &&
-  (line_entry.line != line || line_entry.column != column_num) &&
-  resolve_scope & eSymbolContextLineEntry && check_inlines) {
+  (line_entry.line != line || (column_num != 0 && line_entry.column != 
column_num))
+  && (resolve_scope & eSymbolContextLineEntry) && check_inlines) {
 // We don't move lines over function boundaries, so the address in the
 // line entry will be the in function that contained the line that might
 // be a CallSite, and we can just iterate over that function to find any
 // inline records, and dig up their call sites.
 Address start_addr = line_entry.range.GetBaseAddress();
 Function *function = start_addr.CalculateSymbolContextFunction();
+// Record the size of the list to see if we added to it:
+size_t old_sc_list_size = sc_list.GetSize();
 
 Declaration sought_decl(file_spec, line, column_num);
 // We use this recursive function to descend the block structure looking
@@ -417,7 +419,7 @@ void CompileUnit::ResolveSymbolContext(
 // FIXME: Should I also do this for "call site line exists between the
 // given line number and the later line we found in the line table"?  
That's
 // a closer approximation to our general sliding algorithm.
-if (sc_list.GetSize())
+if (sc_list.GetSize() > old_sc_list_size)
   return;
   }
 
But I'm kind of surprised that nothing in our test suite was sensitive to this. 
 I'll work up this example into a test, and then submit this.  

Thanks for the example!

Jim


> On Nov 4, 2024, at 9:36 AM, Jim Ingham ***@***.***> wrote:
> 
> Give me a bit to look at this.  The intention of this patch was just to add 
> more locations, it shouldn't be reducing the number of breakpoints.  There's 
> likely some simple goof here.
> 
> Jim
> 
> 
>> On Nov 4, 2024, at 2:44 AM, Pavel Labath ***@***.***> wrote:
>> 
>> 
>> So it sounds like the problem is that lldb no longer looks for all compile 
>> units with the given name when setting a breakpoint. Changing that doesn't 
>> seem like it was the intention of this patch. Jim, is there an easy fix for 
>> this or should we revert the patch for now?
>> 
>> —
>> 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/114158
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][breakpoint] Grey out disabled breakpoints (PR #91404)

2024-11-04 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,32 @@
+"""
+Test that disabling breakpoints and viewing them in a list uses the correct 
ANSI color settings when colors are enabled and disabled.
+"""
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+import re
+import io
+
+
+class DisabledBreakpointsTest(PExpectTest):
+@add_test_categories(["pexpect"])
+def test_disabling_breakpoints_with_color(self):
+"""Test that disabling a breakpoint and viewing the breakpoints list 
uses the specified ANSI color prefix."""
+import pexpect
+
+self.child = pexpect.spawn("expect", encoding="utf-8")
+

chelcassanova wrote:

This line is probably unnecessary, I was modeling this test after another 
`pexpect` test that spawns pexpect with the `expect` program but I don't think 
this tests needs that now that I'm looking at this again, I can remove this.

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


[Lldb-commits] [lldb] 8f8e2b7 - [lldb] Improve locking in PathMappingLists (NFC) (#114576)

2024-11-04 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2024-11-04T11:55:09-08:00
New Revision: 8f8e2b732635f03dc646a3c98db0b58a051745b8

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

LOG: [lldb] Improve locking in PathMappingLists (NFC) (#114576)

In [D148380](https://reviews.llvm.org/D148380), Alex added locking to
PathMappingLists. The current implementation runs the callback under the
lock, which I don't believe is necessary. As far as I can tell, no users
of the callback are relying on the list not having been modified until
the callback is handled.

This patch implements my suggestion to unlock the mutex before the
callback. I also switched to a non-recursive mutex as I don't believe
the recursive property is needed. To make the class fully thread safe, I
did have to introduce another mutex to protect the callback members.

The motivation for this change is #114507. Specifically,
Target::SetExecutableModule calls Target::GetOrCreateModule, which
potentially performs path remapping, which in turns has a callback to
Target::SetExecutableModule.

Added: 


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

Removed: 




diff  --git a/lldb/include/lldb/Target/PathMappingList.h 
b/lldb/include/lldb/Target/PathMappingList.h
index 1c0ff564739c5a..825278cf9afbc8 100644
--- a/lldb/include/lldb/Target/PathMappingList.h
+++ b/lldb/include/lldb/Target/PathMappingList.h
@@ -25,7 +25,6 @@ class PathMappingList {
   typedef void (*ChangedCallback)(const PathMappingList &path_list,
   void *baton);
 
-  // Constructors and Destructors
   PathMappingList();
 
   PathMappingList(ChangedCallback callback, void *callback_baton);
@@ -53,12 +52,12 @@ class PathMappingList {
   llvm::json::Value ToJSON();
 
   bool IsEmpty() const {
-std::lock_guard lock(m_mutex);
+std::lock_guard lock(m_pairs_mutex);
 return m_pairs.empty();
   }
 
   size_t GetSize() const {
-std::lock_guard lock(m_mutex);
+std::lock_guard lock(m_pairs_mutex);
 return m_pairs.size();
   }
 
@@ -134,28 +133,35 @@ class PathMappingList {
   /// The newly remapped filespec that is guaranteed to exist.
   std::optional FindFile(const FileSpec &orig_spec) const;
 
-  uint32_t FindIndexForPath(llvm::StringRef path) const;
-
   uint32_t GetModificationID() const {
-std::lock_guard lock(m_mutex);
+std::lock_guard lock(m_pairs_mutex);
 return m_mod_id;
   }
 
 protected:
-  mutable std::recursive_mutex m_mutex;
   typedef std::pair pair;
   typedef std::vector collection;
   typedef collection::iterator iterator;
   typedef collection::const_iterator const_iterator;
 
+  void AppendNoLock(llvm::StringRef path, llvm::StringRef replacement);
+  uint32_t FindIndexForPathNoLock(llvm::StringRef path) const;
+  void Notify(bool notify) const;
+
   iterator FindIteratorForPath(ConstString path);
 
   const_iterator FindIteratorForPath(ConstString path) const;
 
   collection m_pairs;
+  mutable std::mutex m_pairs_mutex;
+
   ChangedCallback m_callback = nullptr;
   void *m_callback_baton = nullptr;
-  uint32_t m_mod_id = 0; // Incremented anytime anything is added or removed.
+  mutable std::mutex m_callback_mutex;
+
+  /// Incremented anytime anything is added to or removed from m_pairs. Also
+  /// protected by m_pairs_mutex.
+  uint32_t m_mod_id = 0;
 };
 
 } // namespace lldb_private

diff  --git a/lldb/source/Target/PathMappingList.cpp 
b/lldb/source/Target/PathMappingList.cpp
index 9c283b0146fe07..16456d110a9336 100644
--- a/lldb/source/Target/PathMappingList.cpp
+++ b/lldb/source/Target/PathMappingList.cpp
@@ -48,7 +48,8 @@ PathMappingList::PathMappingList(const PathMappingList &rhs)
 
 const PathMappingList &PathMappingList::operator=(const PathMappingList &rhs) {
   if (this != &rhs) {
-std::scoped_lock 
locks(m_mutex, rhs.m_mutex);
+std::scoped_lock locks(
+m_callback_mutex, m_pairs_mutex, rhs.m_pairs_mutex);
 m_pairs = rhs.m_pairs;
 m_callback = nullptr;
 m_callback_baton = nullptr;
@@ -59,85 +60,111 @@ const PathMappingList &PathMappingList::operator=(const 
PathMappingList &rhs) {
 
 PathMappingList::~PathMappingList() = default;
 
-void PathMappingList::Append(llvm::StringRef path, llvm::StringRef replacement,
- bool notify) {
-  std::lock_guard lock(m_mutex);
+void PathMappingList::AppendNoLock(llvm::StringRef path,
+   llvm::StringRef replacement) {
   ++m_mod_id;
   m_pairs.emplace_back(pair(NormalizePath(path), NormalizePath(replacement)));
-  if (notify && m_callback)
-m_callback(*this, m_callback_baton);
+}
+
+void PathMappingList::Notify(bool notify) const {
+  ChangedCallback callback = nullptr;
+  void *baton = nullptr;
+  {
+st

[Lldb-commits] [lldb] [lldb][breakpoint] Grey out disabled breakpoints (PR #91404)

2024-11-04 Thread Chelsea Cassanova via lldb-commits

https://github.com/chelcassanova updated 
https://github.com/llvm/llvm-project/pull/91404

>From c683d86ea988e76500ed12d1ac102fc1cc091823 Mon Sep 17 00:00:00 2001
From: Chelsea Cassanova 
Date: Thu, 9 May 2024 11:08:29 -0700
Subject: [PATCH] [lldb][breakpoint] Grey out disabled breakpoints

This commit adds colour settings to the list of breakpoints in order to
grey out breakpoints that have been disabled.
---
 lldb/include/lldb/API/SBStream.h  |  5 
 lldb/include/lldb/Core/Debugger.h |  4 +++
 lldb/include/lldb/Utility/Stream.h|  8 ++
 lldb/source/API/SBStream.cpp  | 10 +++
 lldb/source/Breakpoint/Breakpoint.cpp | 11 
 lldb/source/Core/CoreProperties.td| 10 +++
 lldb/source/Core/Debugger.cpp | 12 +
 lldb/source/Utility/Stream.cpp|  8 ++
 .../API/terminal/TestDisabledBreakpoints.py   | 27 +++
 9 files changed, 95 insertions(+)
 create mode 100644 lldb/test/API/terminal/TestDisabledBreakpoints.py

diff --git a/lldb/include/lldb/API/SBStream.h b/lldb/include/lldb/API/SBStream.h
index d230da6123fb36..66a56322a9f958 100644
--- a/lldb/include/lldb/API/SBStream.h
+++ b/lldb/include/lldb/API/SBStream.h
@@ -12,6 +12,7 @@
 #include 
 
 #include "lldb/API/SBDefines.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace lldb_private {
 class ScriptInterpreter;
@@ -47,6 +48,10 @@ class LLDB_API SBStream {
 
   void Print(const char *str);
 
+  bool HasColor();
+
+  void FormatAnsiTerminalCodes(llvm::StringRef format);
+
   void RedirectToFile(const char *path, bool append);
 
   void RedirectToFile(lldb::SBFile file);
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 1d5f2fcc20626c..4f04335b42bbc7 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -308,6 +308,10 @@ class Debugger : public 
std::enable_shared_from_this,
 
   llvm::StringRef GetShowProgressAnsiSuffix() const;
 
+  llvm::StringRef GetDisabledBreakpointAnsiPrefix() const;
+
+  llvm::StringRef GetDisabledBreakpointAnsiSuffix() const;
+
   bool GetUseAutosuggestion() const;
 
   llvm::StringRef GetAutosuggestionAnsiPrefix() const;
diff --git a/lldb/include/lldb/Utility/Stream.h 
b/lldb/include/lldb/Utility/Stream.h
index 37bcdc99241715..1ab590202cd694 100644
--- a/lldb/include/lldb/Utility/Stream.h
+++ b/lldb/include/lldb/Utility/Stream.h
@@ -309,6 +309,12 @@ class Stream {
   /// The current indentation level.
   unsigned GetIndentLevel() const;
 
+  /// Whether or not the stream is using color.
+  ///
+  /// \return
+  /// The color setting of the stream.
+  bool HasColor();
+
   /// Indent the current line in the stream.
   ///
   /// Indent the current line using the current indentation level and print an
@@ -366,6 +372,8 @@ class Stream {
   /// The optional C string format that can be overridden.
   void QuotedCString(const char *cstr, const char *format = "\"%s\"");
 
+  void FormatAnsiTerminalCodes(llvm::StringRef format);
+
   /// Set the address size in bytes.
   ///
   /// \param[in] addr_size
diff --git a/lldb/source/API/SBStream.cpp b/lldb/source/API/SBStream.cpp
index fc8f09a7bb9ae5..bc0f3356d4753c 100644
--- a/lldb/source/API/SBStream.cpp
+++ b/lldb/source/API/SBStream.cpp
@@ -11,6 +11,7 @@
 #include "lldb/API/SBFile.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/StreamFile.h"
+#include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/Instrumentation.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Status.h"
@@ -77,6 +78,15 @@ void SBStream::Printf(const char *format, ...) {
   va_end(args);
 }
 
+bool SBStream::HasColor() {
+  return m_opaque_up->AsRawOstream().colors_enabled();
+}
+
+void SBStream::FormatAnsiTerminalCodes(llvm::StringRef format) {
+  if (HasColor())
+Printf("%s", ansi::FormatAnsiTerminalCodes(format).c_str());
+}
+
 void SBStream::RedirectToFile(const char *path, bool append) {
   LLDB_INSTRUMENT_VA(this, path, append);
 
diff --git a/lldb/source/Breakpoint/Breakpoint.cpp 
b/lldb/source/Breakpoint/Breakpoint.cpp
index 54ebafc3f65b5c..550671bfbee9d9 100644
--- a/lldb/source/Breakpoint/Breakpoint.cpp
+++ b/lldb/source/Breakpoint/Breakpoint.cpp
@@ -15,6 +15,7 @@
 #include "lldb/Breakpoint/BreakpointResolver.h"
 #include "lldb/Breakpoint/BreakpointResolverFileLine.h"
 #include "lldb/Core/Address.h"
+#include "lldb/Core/Debugger.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/SearchFilter.h"
@@ -26,6 +27,7 @@
 #include "lldb/Target/SectionLoadList.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/ThreadSpec.h"
+#include "lldb/Utility/AnsiTerminal.h"
 #include "lldb/Utility/LLDBLog.h"
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/Stream.h"
@@ -838,6 +840,11 @@ void Breakpoint::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
 bool show_locations) {
   assert(s 

[Lldb-commits] [lldb] [lldb][breakpoint] Grey out disabled breakpoints (PR #91404)

2024-11-04 Thread Chelsea Cassanova via lldb-commits


@@ -0,0 +1,32 @@
+"""
+Test that disabling breakpoints and viewing them in a list uses the correct 
ANSI color settings when colors are enabled and disabled.
+"""
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+from lldbsuite.test.lldbpexpect import PExpectTest
+
+import re
+import io
+
+
+class DisabledBreakpointsTest(PExpectTest):
+@add_test_categories(["pexpect"])
+def test_disabling_breakpoints_with_color(self):
+"""Test that disabling a breakpoint and viewing the breakpoints list 
uses the specified ANSI color prefix."""
+import pexpect
+
+self.child = pexpect.spawn("expect", encoding="utf-8")
+
+ansi_red_color_code = "\x1b[31m"
+
+self.launch(use_colors=True, dimensions=(100, 100))
+self.child.sendline(

chelcassanova wrote:

If I'm understanding correctly, you mean using `self.expect` instead of 
`self.child.sendline` to set up the breakpoints here? If so, I can change this 
here, I didn't know that `self.expect` checked for the prompt as well. I was 
originally using `sendline` and checking each output with `expect` instead.

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


[Lldb-commits] [lldb] Revert "Fix pointer to reference type (#113596)" (PR #114831)

2024-11-04 Thread via lldb-commits

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


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


[Lldb-commits] [lldb] [llvm] [lldb-dap] Support column breakpoints (PR #113787)

2024-11-04 Thread Pavel Labath via lldb-commits


@@ -910,6 +911,183 @@ void request_attach(const llvm::json::Object &request) {
   }
 }
 
+// "BreakpointLocationsRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "The `breakpointLocations` request returns all possible
+// locations for source breakpoints in a given range.\nClients should only
+// call this request if the corresponding capability
+// `supportsBreakpointLocationsRequest` is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "breakpointLocations" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/BreakpointLocationsArguments"
+//   }
+// },
+// "required": [ "command" ]
+//   }]
+// },
+// "BreakpointLocationsArguments": {
+//   "type": "object",
+//   "description": "Arguments for `breakpointLocations` request.",
+//   "properties": {
+// "source": {
+//   "$ref": "#/definitions/Source",
+//   "description": "The source location of the breakpoints; either
+//   `source.path` or `source.sourceReference` must be specified."
+// },
+// "line": {
+//   "type": "integer",
+//   "description": "Start line of range to search possible breakpoint
+//   locations in. If only the line is specified, the request returns all
+//   possible locations in that line."
+// },
+// "column": {
+//   "type": "integer",
+//   "description": "Start position within `line` to search possible
+//   breakpoint locations in. It is measured in UTF-16 code units and the
+//   client capability `columnsStartAt1` determines whether it is 0- or
+//   1-based. If no column is given, the first position in the start line 
is
+//   assumed."
+// },
+// "endLine": {
+//   "type": "integer",
+//   "description": "End line of range to search possible breakpoint
+//   locations in. If no end line is given, then the end line is assumed to
+//   be the start line."
+// },
+// "endColumn": {
+//   "type": "integer",
+//   "description": "End position within `endLine` to search possible
+//   breakpoint locations in. It is measured in UTF-16 code units and the
+//   client capability `columnsStartAt1` determines whether it is 0- or
+//   1-based. If no end column is given, the last position in the end line
+//   is assumed."
+// }
+//   },
+//   "required": [ "source", "line" ]
+// },
+// "BreakpointLocationsResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to `breakpointLocations` request.\nContains
+// possible locations for source breakpoints.",
+// "properties": {
+//   "body": {
+// "type": "object",
+// "properties": {
+//   "breakpoints": {
+// "type": "array",
+// "items": {
+//   "$ref": "#/definitions/BreakpointLocation"
+// },
+// "description": "Sorted set of possible breakpoint locations."
+//   }
+// },
+// "required": [ "breakpoints" ]
+//   }
+// },
+// "required": [ "body" ]
+//   }]
+// },
+// "BreakpointLocation": {
+//   "type": "object",
+//   "description": "Properties of a breakpoint location returned from the
+//   `breakpointLocations` request.",
+//   "properties": {
+// "line": {
+//   "type": "integer",
+//   "description": "Start line of breakpoint location."
+// },
+// "column": {
+//   "type": "integer",
+//   "description": "The start position of a breakpoint location. Position
+//   is measured in UTF-16 code units and the client capability
+//   `columnsStartAt1` determines whether it is 0- or 1-based."
+// },
+// "endLine": {
+//   "type": "integer",
+//   "description": "The end line of breakpoint location if the location
+//   covers a range."
+// },
+// "endColumn": {
+//   "type": "integer",
+//   "description": "The end position of a breakpoint location (if the
+//   location covers a range). Position is measured in UTF-16 code units 
and
+//   the client capability `columnsStartAt1` determines whether it is 0- or
+//   1-based."
+// }
+//   },
+//   "required": [ "line" ]
+// },
+void request_breakpointLocations(const llvm::json::Object &request) {
+  llvm::json::Object response;
+  FillResponse(request, response);
+  auto *arguments = request.getObject("arguments");
+  auto *source = arguments->getObject("source");
+  std::string path = GetString(source, "path").str();
+  uint64_t start_line = GetUnsigned(arguments, "line", 0);
+  uint64_t start_column = GetUnsigned(arguments, "column", 0);
+  uint64_t end_line = GetUnsigned(arguments, "endLine", start_line);
+  uint64_t end_column =
+  GetUnsigned(arguments, "endColumn", 
std::numeric_limits::max());
+
+  lldb::SBFileSpec file_spec

[Lldb-commits] [lldb] [LLDB] Finish implementing support for DW_FORM_data16 (PR #113508)

2024-11-04 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

LGTM

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


[Lldb-commits] [lldb] eee8718 - [lldb][test] TestDataFormatterLibcxxOptionalSimulator.py: skip on Clang-17

2024-11-04 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2024-11-04T11:23:11Z
New Revision: eee8718e26b4ce8972abefc35d2beae96521075f

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

LOG: [lldb][test] TestDataFormatterLibcxxOptionalSimulator.py: skip on Clang-17

A Clang change introduced in this version breaks this test. Said
change was reverted in `52a9ba7ca4fb9427706c28bb3ca15f7a56eecf3f`
in newer versions of Clang.

Added: 


Modified: 

lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/optional/TestDataFormatterLibcxxOptionalSimulator.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/optional/TestDataFormatterLibcxxOptionalSimulator.py
 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/optional/TestDataFormatterLibcxxOptionalSimulator.py
index 7167f4c6c9b5b1..3fefe87dcad970 100644
--- 
a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/optional/TestDataFormatterLibcxxOptionalSimulator.py
+++ 
b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/optional/TestDataFormatterLibcxxOptionalSimulator.py
@@ -47,6 +47,12 @@ def _run_test(self, defines):
 name = f"test_r{r}"
 defines = [f"REVISION={r}"]
 
+# LLDB's FormatterCache caches on DW_AT_name. A change introduced in
+# clang-17 (commit bee886052) changed the contents of DW_AT_name for
+# template specializations, which broke FormatterCache assumptions
+# causing this test to fail. This was reverted in newer version of clang
+# with commit 52a9ba7ca.
+@skipIf(compiler="clang", compiler_version=["=", "17"])
 @functools.wraps(LibcxxOptionalDataFormatterSimulatorTestCase._run_test)
 def test_method(self, defines=defines):
 LibcxxOptionalDataFormatterSimulatorTestCase._run_test(self, defines)



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


[Lldb-commits] [lldb] [lldb] Lookup static const members in FindGlobalVariables (PR #111859)

2024-11-04 Thread Ilia Kuklin via lldb-commits

https://github.com/kuilpd updated 
https://github.com/llvm/llvm-project/pull/111859

>From 4c394ec162b58b3cde3af924a5e9be1de8250a07 Mon Sep 17 00:00:00 2001
From: Ilia Kuklin 
Date: Tue, 30 Jul 2024 17:02:10 +0500
Subject: [PATCH 1/5] [lldb] Lookup static const members in FindGlobalVariables

Static const members initialized inside a class definition might not have a 
corresponding DW_TAG_variable (DWARF 4 and earlier), so they're not indexed by 
ManualDWARFIndex.

Add an additional lookup in FindGlobalVariables. Try looking up the enclosing 
type (e.g. foo::bar for foo::bar::A) and then searching for a static const 
member (A) within this type.
---
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 130 ++
 .../SymbolFile/DWARF/SymbolFileDWARF.h|   3 +
 .../API/python_api/frame/globals/Makefile |   4 +
 .../frame/globals/TestTargetGlobals.py|  43 ++
 .../API/python_api/frame/globals/main.cpp |  12 ++
 5 files changed, 192 insertions(+)
 create mode 100644 lldb/test/API/python_api/frame/globals/Makefile
 create mode 100644 lldb/test/API/python_api/frame/globals/TestTargetGlobals.py
 create mode 100644 lldb/test/API/python_api/frame/globals/main.cpp

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 9287d4baf19e9c..d53da79c1efcee 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2439,6 +2439,48 @@ void SymbolFileDWARF::FindGlobalVariables(
 return variables.GetSize() - original_size < max_matches;
   });
 
+  // If we don't have enough matches and the variable context is not empty, try
+  // to resolve the context as a type and look for static const members.
+  if (variables.GetSize() - original_size < max_matches && !context.empty()) {
+llvm::StringRef type_name;
+if (std::optional parsed_name =
+Type::GetTypeScopeAndBasename(context))
+  type_name = parsed_name->basename;
+else
+  type_name = context;
+
+m_index->GetTypes(ConstString(type_name), [&](DWARFDIE parent) {
+  llvm::StringRef parent_type_name = parent.GetDWARFDeclContext()
+ .GetQualifiedNameAsConstString()
+ .GetStringRef();
+
+  // This type is from another scope, skip it.
+  if (!parent_type_name.ends_with(context))
+return true;
+
+  auto *dwarf_cu = llvm::dyn_cast(parent.GetCU());
+  if (!dwarf_cu)
+return true;
+
+  sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu);
+
+  for (DWARFDIE die = parent.GetFirstChild(); die.IsValid();
+   die = die.GetSibling()) {
+// Try parsing the entry as a static const member.
+if (auto var_sp = ParseStaticConstMemberDIE(sc, die)) {
+  if (var_sp->GetUnqualifiedName().GetStringRef() != basename)
+continue;
+
+  // There can be only one member with a given name.
+  variables.AddVariableIfUnique(var_sp);
+  break;
+}
+  }
+
+  return variables.GetSize() - original_size < max_matches;
+});
+  }
+
   // Return the number of variable that were appended to the list
   const uint32_t num_matches = variables.GetSize() - original_size;
   if (log && num_matches > 0) {
@@ -3371,6 +3413,94 @@ size_t SymbolFileDWARF::ParseVariablesForContext(const 
SymbolContext &sc) {
   return 0;
 }
 
+VariableSP SymbolFileDWARF::ParseStaticConstMemberDIE(
+const lldb_private::SymbolContext &sc, const DWARFDIE &die) {
+  if (die.GetDWARF() != this)
+return die.GetDWARF()->ParseStaticConstMemberDIE(sc, die);
+
+  // Look only for members, ignore all other types of entries.
+  if (die.Tag() != DW_TAG_member)
+return nullptr;
+
+  if (VariableSP var_sp = GetDIEToVariable()[die.GetDIE()])
+return var_sp; // Already been parsed!
+
+  const char *name = nullptr;
+  const char *mangled = nullptr;
+  Declaration decl;
+  DWARFExpression location;
+  DWARFFormValue type_die_form;
+  DWARFFormValue const_value_form;
+
+  DWARFAttributes attributes = die.GetAttributes();
+  const size_t num_attributes = attributes.Size();
+
+  for (size_t i = 0; i < num_attributes; ++i) {
+dw_attr_t attr = attributes.AttributeAtIndex(i);
+DWARFFormValue form_value;
+
+if (!attributes.ExtractFormValueAtIndex(i, form_value))
+  continue;
+
+switch (attr) {
+case DW_AT_decl_file:
+  decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(
+  form_value.Unsigned()));
+  break;
+case DW_AT_decl_line:
+  decl.SetLine(form_value.Unsigned());
+  break;
+case DW_AT_decl_column:
+  decl.SetColumn(form_value.Unsigned());
+  break;
+case DW_AT_name:
+  name = form_value.AsCString();
+  break;
+case DW_AT_type:
+  type_die_form = form_value;
+  break;
+case DW_AT_const_value:
+  const_

[Lldb-commits] [lldb] [lldb] Index static const members of classes, structs and unions as global variables in DWARF 4 and earlier (PR #111859)

2024-11-04 Thread Ilia Kuklin via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Index static const members of classes, structs and unions as global variables in DWARF 4 and earlier (PR #111859)

2024-11-04 Thread Ilia Kuklin via lldb-commits

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


[Lldb-commits] [lldb] [llvm] [lldb-dap] Support column breakpoints (PR #113787)

2024-11-04 Thread Adrian Vogelsgesang via lldb-commits


@@ -910,6 +911,183 @@ void request_attach(const llvm::json::Object &request) {
   }
 }
 
+// "BreakpointLocationsRequest": {
+//   "allOf": [ { "$ref": "#/definitions/Request" }, {
+// "type": "object",
+// "description": "The `breakpointLocations` request returns all possible
+// locations for source breakpoints in a given range.\nClients should only
+// call this request if the corresponding capability
+// `supportsBreakpointLocationsRequest` is true.",
+// "properties": {
+//   "command": {
+// "type": "string",
+// "enum": [ "breakpointLocations" ]
+//   },
+//   "arguments": {
+// "$ref": "#/definitions/BreakpointLocationsArguments"
+//   }
+// },
+// "required": [ "command" ]
+//   }]
+// },
+// "BreakpointLocationsArguments": {
+//   "type": "object",
+//   "description": "Arguments for `breakpointLocations` request.",
+//   "properties": {
+// "source": {
+//   "$ref": "#/definitions/Source",
+//   "description": "The source location of the breakpoints; either
+//   `source.path` or `source.sourceReference` must be specified."
+// },
+// "line": {
+//   "type": "integer",
+//   "description": "Start line of range to search possible breakpoint
+//   locations in. If only the line is specified, the request returns all
+//   possible locations in that line."
+// },
+// "column": {
+//   "type": "integer",
+//   "description": "Start position within `line` to search possible
+//   breakpoint locations in. It is measured in UTF-16 code units and the
+//   client capability `columnsStartAt1` determines whether it is 0- or
+//   1-based. If no column is given, the first position in the start line 
is
+//   assumed."
+// },
+// "endLine": {
+//   "type": "integer",
+//   "description": "End line of range to search possible breakpoint
+//   locations in. If no end line is given, then the end line is assumed to
+//   be the start line."
+// },
+// "endColumn": {
+//   "type": "integer",
+//   "description": "End position within `endLine` to search possible
+//   breakpoint locations in. It is measured in UTF-16 code units and the
+//   client capability `columnsStartAt1` determines whether it is 0- or
+//   1-based. If no end column is given, the last position in the end line
+//   is assumed."
+// }
+//   },
+//   "required": [ "source", "line" ]
+// },
+// "BreakpointLocationsResponse": {
+//   "allOf": [ { "$ref": "#/definitions/Response" }, {
+// "type": "object",
+// "description": "Response to `breakpointLocations` request.\nContains
+// possible locations for source breakpoints.",
+// "properties": {
+//   "body": {
+// "type": "object",
+// "properties": {
+//   "breakpoints": {
+// "type": "array",
+// "items": {
+//   "$ref": "#/definitions/BreakpointLocation"
+// },
+// "description": "Sorted set of possible breakpoint locations."
+//   }
+// },
+// "required": [ "breakpoints" ]
+//   }
+// },
+// "required": [ "body" ]
+//   }]
+// },
+// "BreakpointLocation": {
+//   "type": "object",
+//   "description": "Properties of a breakpoint location returned from the
+//   `breakpointLocations` request.",
+//   "properties": {
+// "line": {
+//   "type": "integer",
+//   "description": "Start line of breakpoint location."
+// },
+// "column": {
+//   "type": "integer",
+//   "description": "The start position of a breakpoint location. Position
+//   is measured in UTF-16 code units and the client capability
+//   `columnsStartAt1` determines whether it is 0- or 1-based."
+// },
+// "endLine": {
+//   "type": "integer",
+//   "description": "The end line of breakpoint location if the location
+//   covers a range."
+// },
+// "endColumn": {
+//   "type": "integer",
+//   "description": "The end position of a breakpoint location (if the
+//   location covers a range). Position is measured in UTF-16 code units 
and
+//   the client capability `columnsStartAt1` determines whether it is 0- or
+//   1-based."
+// }
+//   },
+//   "required": [ "line" ]
+// },
+void request_breakpointLocations(const llvm::json::Object &request) {
+  llvm::json::Object response;
+  FillResponse(request, response);
+  auto *arguments = request.getObject("arguments");
+  auto *source = arguments->getObject("source");
+  std::string path = GetString(source, "path").str();
+  uint64_t start_line = GetUnsigned(arguments, "line", 0);
+  uint64_t start_column = GetUnsigned(arguments, "column", 0);
+  uint64_t end_line = GetUnsigned(arguments, "endLine", start_line);
+  uint64_t end_column =
+  GetUnsigned(arguments, "endColumn", 
std::numeric_limits::max());
+
+  lldb::SBFileSpec file_spec

[Lldb-commits] [lldb] Fix call site breakpoint patch (PR #114158)

2024-11-04 Thread Pavel Labath via lldb-commits

labath wrote:

So it sounds like the problem is that lldb no longer looks for all compile 
units with the given name when setting a breakpoint. Changing that doesn't seem 
like it was the intention of this patch. Jim, is there an easy fix for this or 
should we revert the patch for now?

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


[Lldb-commits] [lldb] [lldb] Index static const members of classes, structs and unions as global variables in DWARF 4 and earlier (PR #111859)

2024-11-04 Thread Michael Buch via lldb-commits


@@ -362,6 +369,18 @@ void ManualDWARFIndex::IndexUnitImpl(DWARFUnit &unit,
 set.namespaces.Insert(ConstString(name), ref);
   break;
 
+case DW_TAG_member: {
+  // In DWARF 4 and earlier `static const` members of a struct, a class or 
a
+  // union have an entry tag `DW_TAG_member`, and are also tagged as
+  // `DW_AT_declaration`, but otherwise follow the same rules as
+  // `DW_TAG_variable`.
+  bool parent_is_class_type = false;
+  if (auto parent = die.GetParent())
+parent_is_class_type = DWARFDIE(&unit, parent).IsStructUnionOrClass();

Michael137 wrote:

Can this just be:
```suggestion
parent_is_class_type = parent->IsStructUnionOrClass();
```
?

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


[Lldb-commits] [lldb] [lldb] Recommend Python 3.8 as the minimum Python version for LLDB (PR #114807)

2024-11-04 Thread Jonas Devlieghere via lldb-commits

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


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