[Lldb-commits] [lldb] [lldb][docs] Update contributing links (PR #69726)

2023-10-23 Thread David Spickett via lldb-commits

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

>From 08c246316c2daa7dde701d5c4beb1de77021520a Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Fri, 20 Oct 2023 14:45:06 +0100
Subject: [PATCH 1/2] [lldb][docs] Update contributing links

Patches now go to PRs, mention the Discord server as well
as the forum.
---
 lldb/docs/index.rst | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lldb/docs/index.rst b/lldb/docs/index.rst
index 2fff25b27b974ea..b8715c066599381 100644
--- a/lldb/docs/index.rst
+++ b/lldb/docs/index.rst
@@ -102,10 +102,13 @@ Additionally it builds:
 See the :doc:`LLDB Build Page ` for build instructions.
 
 Discussions about LLDB should go to the `LLDB forum
-`__. Commit
+`__ or the ``lldb`` channel on
+the LLVM Discord server.
+
+For contributions follow the
+`LLVM contribution process `__. Commit
 messages are automatically sent to the `lldb-commits
-`__ mailing list, and
-this is also the preferred mailing list for patch submissions.
+`__ mailing list.
 
 See the :doc:`Projects page ` if you are looking for some
 interesting areas to contribute to lldb.

>From 5db44df4cefc5352f10d80ad3c7a6a44067cca5d Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 23 Oct 2023 08:39:59 +0100
Subject: [PATCH 2/2] Link to llvm Discord.

---
 lldb/docs/index.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/docs/index.rst b/lldb/docs/index.rst
index b8715c066599381..88ed245b7b27472 100644
--- a/lldb/docs/index.rst
+++ b/lldb/docs/index.rst
@@ -103,7 +103,7 @@ See the :doc:`LLDB Build Page ` for build 
instructions.
 
 Discussions about LLDB should go to the `LLDB forum
 `__ or the ``lldb`` channel on
-the LLVM Discord server.
+the `LLVM Discord server `__.
 
 For contributions follow the
 `LLVM contribution process `__. Commit

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


[Lldb-commits] [lldb] [lldb][docs] Update contributing links (PR #69726)

2023-10-23 Thread David Spickett via lldb-commits


@@ -102,10 +102,13 @@ Additionally it builds:
 See the :doc:`LLDB Build Page ` for build instructions.
 
 Discussions about LLDB should go to the `LLDB forum
-`__. Commit
+`__ or the ``lldb`` channel on
+the LLVM Discord server.

DavidSpickett wrote:

Done.

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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread David Spickett via lldb-commits

DavidSpickett wrote:

I don't have the experience to know if enabling this globally makes sense, but 
I do have a future use case for it.

At a some point I want to be able to describe register fields as enums, and 
having the value as well as the name means you can match it up with the code 
you're debugging and create new code to match the value you're seeing. It's 
also useful for old debuggers on new CPUs where new enum values have been 
added, but we don't know the names yet.

What happens with values that don't have a name, do we already have a fallback 
for that?

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


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-23 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

@bulbazord @JDevlieghere OK this is the second set of refinement where it's 
closer to the structure of BreakpointSites.  It's still not actually doing 
anything -- each one WatchpointResource corresponds to one Watchpoint, a single 
Watchpoint's request is not broken into multiple WatchpointResources, and when 
a watchpoint access is hit, I'm not iterating all of the Watchpoints (lol, all 
1 of them) to bump their hit count, run conditions, etc.  These remaining 
pieces of work will be smaller scale, more complicated I think, and it will be 
easier to consider those parts if the patches are small.

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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread Vlad Serebrennikov via lldb-commits

Endilll wrote:

> What happens with values that don't have a name, do we already have a 
> fallback for that?

I think we do:
https://github.com/llvm/llvm-project/blob/2ad9fde41839879d8805d430c2e0857466d9c5d6/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp#L8563-L8571

Later there is a fallback for `can_be_bitfield == true` code path:
https://github.com/llvm/llvm-project/blob/2ad9fde41839879d8805d430c2e0857466d9c5d6/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp#L8597-L8599

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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread Michael Buch via lldb-commits


@@ -74,9 +74,13 @@ def test(self):
 )
 
 # Test an enum with fixed underlying type.
-self.expect_expr("A::scoped_char_enum_val", result_value="case2")
-self.expect_expr("A::scoped_ll_enum_val_neg", result_value="case0")
-self.expect_expr("A::scoped_ll_enum_val", result_value="case2")
+self.expect_expr("A::scoped_char_enum_val", result_value="case2(2)")
+self.expect_expr(
+"A::scoped_ll_enum_val_neg", 
result_value="case0(-9223372036854775808)"
+)
+self.expect_expr(
+"A::scoped_ll_enum_val", result_value="case2(9223372036854775807)"
+)

Michael137 wrote:

There are some XFAILed test-cases in this file. We should fix those up too so 
the XFAIL occurs for the intended reasons, and not an unexpected format

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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread Michael Buch via lldb-commits


@@ -23,9 +23,18 @@ def check_enum(self, suffix):
 substrs=["Case1", "Case2", "Case3"],
 )
 # Test each case in the enum.
-self.expect_expr("var1_" + suffix, result_type=enum_name, 
result_value="Case1")
-self.expect_expr("var2_" + suffix, result_type=enum_name, 
result_value="Case2")
-self.expect_expr("var3_" + suffix, result_type=enum_name, 
result_value="Case3")
+self.expect(
+"expr var1_" + suffix,
+patterns=[f"\\({enum_name}\\) \\$\\d+ = Case1\\(-?\\d+\\)"],
+)
+self.expect(
+"expr var2_" + suffix,
+patterns=[f"\\({enum_name}\\) \\$\\d+ = Case2\\(-?\\d+\\)"],
+)
+self.expect(
+"expr var3_" + suffix,
+patterns=[f"\\({enum_name}\\) \\$\\d+ = Case3\\(-?\\d+\\)"],

Michael137 wrote:

Why can't we just use `result_value` here?

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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread Vlad Serebrennikov via lldb-commits


@@ -23,9 +23,18 @@ def check_enum(self, suffix):
 substrs=["Case1", "Case2", "Case3"],
 )
 # Test each case in the enum.
-self.expect_expr("var1_" + suffix, result_type=enum_name, 
result_value="Case1")
-self.expect_expr("var2_" + suffix, result_type=enum_name, 
result_value="Case2")
-self.expect_expr("var3_" + suffix, result_type=enum_name, 
result_value="Case3")
+self.expect(
+"expr var1_" + suffix,
+patterns=[f"\\({enum_name}\\) \\$\\d+ = Case1\\(-?\\d+\\)"],
+)
+self.expect(
+"expr var2_" + suffix,
+patterns=[f"\\({enum_name}\\) \\$\\d+ = Case2\\(-?\\d+\\)"],
+)
+self.expect(
+"expr var3_" + suffix,
+patterns=[f"\\({enum_name}\\) \\$\\d+ = Case3\\(-?\\d+\\)"],

Endilll wrote:

I tried to do that initially, but then I realized that actual values of 
`Case1`, `Case2`, and `Case3` differ on invocations of this function. It might 
not be apparent at the first glance, but those asserts are a part of 
`check_enum` function which is called 10 times at the end of this file. 

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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> I think we do:

I commented those out and got a bunch of test failures, so we're good on 
coverage there.

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


[Lldb-commits] [lldb] [lldb] Add a single bit constructor for RegisterFlags::Field (PR #69315)

2023-10-23 Thread David Spickett via lldb-commits

DavidSpickett wrote:

@bulbazord Ok to land this? (looks like I'll be going ahead with the work 
presented in the RFC)

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


[Lldb-commits] [lldb] [mlir] Add config for PDL (PR #69927)

2023-10-23 Thread Jacques Pienaar via lldb-commits

https://github.com/jpienaar updated 
https://github.com/llvm/llvm-project/pull/69927

>From eea36708d838411d70eb99265c3a2f3aabb91460 Mon Sep 17 00:00:00 2001
From: Jacques Pienaar 
Date: Sun, 22 Oct 2023 09:33:40 -0700
Subject: [PATCH] [mlir] Add config for PDL

Make it so that PDL can be optionally disabled. PDL is different than
other dialects as its included in rewrite framework. This results in
these being included even where it isn't used and not removed during
compilation. Add option to disable for workloads where it isn't needed
or used. This ends up being rather invasive due to how PDL is included.
Ideally we'd have less ifdefs, not particularly happy with those, but
given how integrated it is, couldn't see simple alternative.

PDL is enabled by default (and not optional bazel).

This only works with tests disabled. With tests enabled this still
compiles but tests fail as there is no lit config to disable tests that
depend on PDL yet.
---
 mlir/CMakeLists.txt   | 12 ++--
 mlir/cmake/modules/AddMLIR.cmake  |  3 +
 mlir/examples/CMakeLists.txt  |  4 +-
 mlir/examples/minimal-opt/README.md   |  7 ++-
 mlir/include/mlir/Config/mlir-config.h.cmake  |  3 +
 mlir/include/mlir/Conversion/Passes.td|  2 +
 mlir/include/mlir/Dialect/CMakeLists.txt  |  6 +-
 .../mlir/Dialect/Transform/CMakeLists.txt |  4 +-
 mlir/include/mlir/IR/PatternMatch.h   | 17 +
 mlir/include/mlir/InitAllDialects.h   |  9 ++-
 mlir/include/mlir/InitAllExtensions.h | 11 +++-
 .../mlir/Rewrite/FrozenRewritePatternSet.h|  6 ++
 mlir/include/mlir/Rewrite/PatternApplicator.h |  5 ++
 .../mlir/Transforms/DialectConversion.h   |  2 +
 mlir/lib/CAPI/Dialect/CMakeLists.txt  | 18 +++---
 mlir/lib/Conversion/CMakeLists.txt|  4 +-
 mlir/lib/Dialect/Bufferization/CMakeLists.txt |  4 +-
 .../Bufferization/TransformOps/CMakeLists.txt |  1 -
 mlir/lib/Dialect/CMakeLists.txt   |  6 +-
 mlir/lib/Dialect/Transform/CMakeLists.txt |  4 +-
 mlir/lib/IR/PatternMatch.cpp  |  2 +
 mlir/lib/Rewrite/CMakeLists.txt   | 24 +--
 mlir/lib/Rewrite/FrozenRewritePatternSet.cpp  | 13 +++-
 mlir/lib/Rewrite/PatternApplicator.cpp| 26 +++-
 mlir/lib/Tools/CMakeLists.txt |  6 +-
 .../Transforms/Utils/DialectConversion.cpp|  2 +
 mlir/python/CMakeLists.txt| 62 ++-
 mlir/test/CAPI/CMakeLists.txt | 16 ++---
 mlir/test/CMakeLists.txt  | 20 --
 mlir/test/lib/Dialect/CMakeLists.txt  |  5 +-
 mlir/test/lib/Rewrite/CMakeLists.txt  |  3 +-
 mlir/test/lib/Tools/CMakeLists.txt|  4 +-
 mlir/test/lib/Transforms/CMakeLists.txt   | 28 ++---
 mlir/tools/CMakeLists.txt |  4 +-
 mlir/tools/mlir-lsp-server/CMakeLists.txt | 10 ++-
 .../tools/mlir-lsp-server/mlir-lsp-server.cpp |  4 ++
 mlir/tools/mlir-opt/CMakeLists.txt| 10 ++-
 mlir/tools/mlir-opt/mlir-opt.cpp  | 16 +++--
 mlir/unittests/Conversion/CMakeLists.txt  |  4 +-
 mlir/unittests/Dialect/CMakeLists.txt |  4 +-
 .../llvm-project-overlay/mlir/BUILD.bazel |  1 +
 41 files changed, 283 insertions(+), 109 deletions(-)

diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index ac120aad0d1eda7..d0db9e341765b3d 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -132,6 +132,8 @@ set(MLIR_ENABLE_NVPTXCOMPILER 0 CACHE BOOL
 "Statically link the nvptxlibrary instead of calling ptxas as a subprocess 
\
 for compiling PTX to cubin")
 
+set(MLIR_ENABLE_PDL 1 CACHE BOOL "Enable PDL")
+
 option(MLIR_INCLUDE_TESTS
"Generate build targets for the MLIR unit tests."
${LLVM_INCLUDE_TESTS})
@@ -179,12 +181,14 @@ include_directories( ${MLIR_INCLUDE_DIR})
 # from another directory like tools
 add_subdirectory(tools/mlir-tblgen)
 add_subdirectory(tools/mlir-linalg-ods-gen)
-add_subdirectory(tools/mlir-pdll)
-
 set(MLIR_TABLEGEN_EXE "${MLIR_TABLEGEN_EXE}" CACHE INTERNAL "")
 set(MLIR_TABLEGEN_TARGET "${MLIR_TABLEGEN_TARGET}" CACHE INTERNAL "")
-set(MLIR_PDLL_TABLEGEN_EXE "${MLIR_PDLL_TABLEGEN_EXE}" CACHE INTERNAL "")
-set(MLIR_PDLL_TABLEGEN_TARGET "${MLIR_PDLL_TABLEGEN_TARGET}" CACHE INTERNAL "")
+
+if(MLIR_ENABLE_PDL)
+  add_subdirectory(tools/mlir-pdll)
+  set(MLIR_PDLL_TABLEGEN_EXE "${MLIR_PDLL_TABLEGEN_EXE}" CACHE INTERNAL "")
+  set(MLIR_PDLL_TABLEGEN_TARGET "${MLIR_PDLL_TABLEGEN_TARGET}" CACHE INTERNAL 
"")
+endif()
 
 add_subdirectory(include/mlir)
 add_subdirectory(lib)
diff --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake
index 544abe43688820e..f20a2bc75d5433b 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -6,6 +6,9 @@ include(LLVMDistributionSupport)
 file(REMOVE ${CMAKE_BINARY_DIR}/tablegen_compile_commands.yml)
 
 function(mlir_tablegen ofn)
+  if (MLIR_ENABLE_PDL)

[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-10-23 Thread David Spickett via lldb-commits


@@ -1506,13 +1513,39 @@ static bool LookupAddressInModule(CommandInterpreter 
&interpreter, Stream &strm,
 
 ExecutionContextScope *exe_scope =
 interpreter.GetExecutionContext().GetBestExecutionContextScope();
-DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm);
+DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm, nullptr);

DavidSpickett wrote:

So the point of the default argument is that you don't need to pass a nullptr 
here. If you don't pass anything, it defaults to nullptr.

This means all existing calls stay the same and only paths where your matching 
took place would pass an argument here.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-10-23 Thread David Spickett via lldb-commits


@@ -1548,14 +1581,17 @@ static uint32_t LookupSymbolInModule(CommandInterpreter 
&interpreter,
   Symbol *symbol = symtab->SymbolAtIndex(match_indexes[i]);
   if (symbol) {
 if (symbol->ValueIsAddress()) {
+  // Using the new dump function to add colors in the summary.

DavidSpickett wrote:

If these are for your own info when developing, cool. It's a nice habit to get 
into, but later we'll go through and remove all these that are "obvious" in 
production code.

One thing I do is `// TODO: ...`. Then before I push for review I can do `git 
show | grep TODO` and see if I forgot anything.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-10-23 Thread David Spickett via lldb-commits


@@ -642,7 +680,11 @@ bool Address::Dump(Stream *s, ExecutionContextScope 
*exe_scope, DumpStyle style,
 if (pointer_sc.function != nullptr ||
 pointer_sc.symbol != nullptr) {
   s->PutCString(": ");
-  pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, 
false,
+  if(name)
+pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, 
false,
+ false, true, true, name);
+  else
+pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, 
false,

DavidSpickett wrote:

Here you can simplify this a lot.

If `if (name)` is true, then `name` is not nullptr. So:
```
pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false,
 false, true, true, name);
```
Is fine. Ok so far.

In the `else`, `name` must be `nullptr`. `DumpStopContext`'s name parameter 
defaults to `nullptr` anyway, so by passing it here too, you wouldn't create 
any problems.

So the final code could be:



  if(name)
pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, 
false,
 false, true, true, name);
  else
pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, 
false,
 

Here you can simplify this a lot.

If `if (name)` is true, then `name` is not nullptr. So:
```
pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, false,
 false, true, true, name);
```
Is fine. Ok so far.

In the `else`, `name` must be `nullptr`. `DumpStopContext`'s name parameter 
defaults to `nullptr` anyway, so by passing it here too, you wouldn't create 
any problems.

So the final code could be:
```
pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, 
false,
 false, true, true, name);
```
If name is nullptr, we pass a nullptr, if it isn't, we pass it on. 
`DumpStopContext` is happy with either.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-10-23 Thread David Spickett via lldb-commits


@@ -680,21 +722,33 @@ bool Address::Dump(Stream *s, ExecutionContextScope 
*exe_scope, DumpStyle style,
 if (show_stop_context) {
   // We have a function or a symbol from the same sections as this
   // address.
-  sc.DumpStopContext(s, exe_scope, *this, show_fullpaths,
- show_module, show_inlined_frames,
- show_function_arguments, show_function_name);
+  // Using the same logic, hecking if searched symbol passed to 
this function or if it using the defualt nullptr
+  if(name)
+sc.DumpStopContext(s, exe_scope, *this, show_fullpaths,
+  show_module, show_inlined_frames,
+  show_function_arguments, show_function_name, 
name);
+  else
+sc.DumpStopContext(s, exe_scope, *this, show_fullpaths,
+  show_module, show_inlined_frames,
+  show_function_arguments, show_function_name);

DavidSpickett wrote:

You can apply what I talked about above to this and all the following `if 
(name)` I'm sure :)

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-10-23 Thread David Spickett via lldb-commits


@@ -680,21 +722,33 @@ bool Address::Dump(Stream *s, ExecutionContextScope 
*exe_scope, DumpStyle style,
 if (show_stop_context) {
   // We have a function or a symbol from the same sections as this
   // address.
-  sc.DumpStopContext(s, exe_scope, *this, show_fullpaths,
- show_module, show_inlined_frames,
- show_function_arguments, show_function_name);
+  // Using the same logic, hecking if searched symbol passed to 
this function or if it using the defualt nullptr
+  if(name)
+sc.DumpStopContext(s, exe_scope, *this, show_fullpaths,
+  show_module, show_inlined_frames,
+  show_function_arguments, show_function_name, 
name);
+  else
+sc.DumpStopContext(s, exe_scope, *this, show_fullpaths,
+  show_module, show_inlined_frames,
+  show_function_arguments, show_function_name);
 } else {
   // We found a symbol but it was in a different section so it
   // isn't the symbol we should be showing, just show the section
   // name + offset
-  Dump(s, exe_scope, DumpStyleSectionNameOffset);
+  if(name)
+Dump(s, exe_scope, DumpStyleSectionNameOffset, 
DumpStyleInvalid, UINT32_MAX, false, name);
+  else
+Dump(s, exe_scope, DumpStyleSectionNameOffset);
 }
   }
 }
   }
 } else {
-  if (fallback_style != DumpStyleInvalid)
+  if (fallback_style != DumpStyleInvalid && !name)
 return Dump(s, exe_scope, fallback_style, DumpStyleInvalid, addr_size);
+  else if(fallback_style != DumpStyleInvalid && name){
+return Dump(s, exe_scope, fallback_style, DumpStyleInvalid, addr_size, 
false, name);

DavidSpickett wrote:

Here your one call would be:
```
return Dump(s, exe_scope, fallback_style, DumpStyleInvalid, addr_size, false, 
name);
```
Given that the previous call effectively passed `false` as well.


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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-10-23 Thread David Spickett via lldb-commits


@@ -185,6 +226,111 @@ bool SymbolContext::DumpStopContext(Stream *s, 
ExecutionContextScope *exe_scope,
   return dumped_something;
 }
 
+void SymbolContext::GetDescription(Stream *s, lldb::DescriptionLevel level,
+   Target *target, const char* name) const {

DavidSpickett wrote:

Did we need a second copy of this function? I assume it existed prior.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-10-23 Thread David Spickett via lldb-commits


@@ -1506,13 +1513,39 @@ static bool LookupAddressInModule(CommandInterpreter 
&interpreter, Stream &strm,
 
 ExecutionContextScope *exe_scope =
 interpreter.GetExecutionContext().GetBestExecutionContextScope();
-DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm);
+DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm, nullptr);
 return true;
   }
 
   return false;
 }
 
+//===
+
+// This function is the one which colorizes the regex symbol searched
+static void PrintRed(Stream &strm, const char *text, const char *name) {
+const std::string red_start = ANSI_ESC_START + 
std::to_string(ANSI_FG_COLOR_RED) + ANSI_ESC_END;
+const std::string reset_color = ANSI_ESC_START + 
std::to_string(ANSI_CTRL_NORMAL) + ANSI_ESC_END;
+
+const char *match = text;
+size_t name_len = strlen(name);

DavidSpickett wrote:

https://en.cppreference.com/w/c/string/byte/strlen

Specifically:
```
The behavior is undefined if str is not a pointer to a null-terminated byte 
string.
```
I won't go into what that means according to the standard but here 
specifically, if clang knew a call to PrintRed took a nullptr always, it could 
make essentially choose the result of strlen to be almost anything. Which is 
not what we want.

So, as you suggested in your comment on the PR page, starting with some `if a 
nullptr then just print it out normally` is a good idea.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-10-23 Thread David Spickett via lldb-commits


@@ -1506,13 +1513,39 @@ static bool LookupAddressInModule(CommandInterpreter 
&interpreter, Stream &strm,
 
 ExecutionContextScope *exe_scope =
 interpreter.GetExecutionContext().GetBestExecutionContextScope();
-DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm);
+DumpAddress(exe_scope, so_addr, verbose, all_ranges, strm, nullptr);
 return true;
   }
 
   return false;
 }
 
+//===
+
+// This function is the one which colorizes the regex symbol searched
+static void PrintRed(Stream &strm, const char *text, const char *name) {
+const std::string red_start = ANSI_ESC_START + 
std::to_string(ANSI_FG_COLOR_RED) + ANSI_ESC_END;
+const std::string reset_color = ANSI_ESC_START + 
std::to_string(ANSI_CTRL_NORMAL) + ANSI_ESC_END;
+
+const char *match = text;
+size_t name_len = strlen(name);

DavidSpickett wrote:

https://en.cppreference.com/w/c/string/byte/strstr

```
The behavior is undefined if either str or substr is not a pointer to a 
null-terminated byte string.
```

You see the theme, a lot of these functions do not check for you.

It may be helpful that a pointer to the empty string `""` will not be nullptr, 
a nullptr literally cannot point to anything, it's an invalid pointer (sort of, 
see the standards if you want the super specific language).

The point being that when you're coming from a language without strings that 
can be null and can only be empty string or some characters, that difference 
can be confusing.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-10-23 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Cool, some good improvements so far.

> Instead of this, should I call the next dump function with name parameter and 
> handle the name=nullptr in the PrintRed function.

It would be a good idea to do this yes. I left some comments suggesting things 
to check there.

I would do that and remove the redundant `else`s, then move on to replacing 
PrintRed with the built in function I mentioned.

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


[Lldb-commits] [lldb] Colorize output when searching for symbols in lldb (PR #69422)

2023-10-23 Thread David Spickett via lldb-commits


@@ -642,7 +680,11 @@ bool Address::Dump(Stream *s, ExecutionContextScope 
*exe_scope, DumpStyle style,
 if (pointer_sc.function != nullptr ||
 pointer_sc.symbol != nullptr) {
   s->PutCString(": ");
-  pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, 
false,
+  if(name)
+pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, 
false,
+ false, true, true, name);
+  else
+pointer_sc.DumpStopContext(s, exe_scope, so_addr, true, 
false,

DavidSpickett wrote:

This may help you see what's going on behind the scenes: 
https://godbolt.org/z/vxc56798P

You can ignore the assembly specifics but for the fact that fn2 and fn3 
generate identical code. Just in the source code one "explicitly" passes 
nullptr, and one "implicitly" passes it.

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


[Lldb-commits] [lldb] [lldb] Check for duplicate interpreter modules without loading them (PR #69932)

2023-10-23 Thread David Spickett via lldb-commits

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

Fixes #68987

Early on we load the interpreter (most commonly ld-linux) in 
LoadInterpreterModule. Then later when we get the first DYLD rendezvous we get 
a list of libraries that commonly includes ld-linux again.

Previously we would load this duplicate, see that it was a duplicate, and 
unload it.

Problem was that this unloaded the section information of the first copy of 
ld-linux. On platforms where you can place a breakpoint using only an address, 
this wasn't an issue.

On ARM you have ARM and Thumb modes. We must know which one the section we're 
breaking in is, otherwise we'll go there in the wrong mode and SIGILL. This 
happened on ARM when lldb tried to call mmap during expression evaluation.

To fix this, I am making the assumption that the base address we see in the 
module prior to loading can be compared with what we know the interpreter base 
address is. Then we don't have to load the module to know we can ignore it.

This fixes the lldb test suite on Ubuntu versions where 
https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/1927192 has been fixed. 
Which was recently done on Jammy.

>From b82be6da03cc7a38ad8dbc0e27508cbbd3a4000a Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Fri, 20 Oct 2023 10:56:30 +
Subject: [PATCH] [lldb] Check for duplicate interpreter modules without
 loading them

Fixes #68987

Early on we load the interpreter (most commonly ld-linux) in
LoadInterpreterModule. Then later when we get the first DYLD
rendezvous we get a list of libraries that commonly includes ld-linux
again.

Previously we would load this duplicate, see that it was a duplicate,
and unload it.

Problem was that this unloaded the section information of the first
copy of ld-linux. On platforms where you can place a breakpoint
using only an address, this wasn't an issue.

On ARM you have ARM and Thumb modes. We must know which one the section
we're breaking in is, otherwise we'll go there in the wrong mode and SIGILL.
This happened on ARM when lldb tried to call mmap during expression
evaluation.

To fix this, I am making the assumption that the base address we see
in the module prior to loading can be compared with what we know
the interpreter base address is. Then we don't have to load the
module to know we can ignore it.

This fixes the lldb test suite on Ubuntu versions where
https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/1927192 has been fixed.
Which was recently done on Jammy.
---
 .../POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp   | 17 -
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git 
a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index c427b476089e458..3d65f496742099d 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -437,6 +437,14 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() {
   m_initial_modules_added = true;
 }
 for (; I != E; ++I) {
+  // Don't load a duplicate copy of ld.so if we have already loaded it
+  // earlier in LoadInterpreterModule. If we instead loaded then unloaded 
it
+  // later, the section information for ld.so would be removed. That
+  // information is required for placing breakpoints on Arm/Thumb systems.
+  if ((m_interpreter_module.lock() != nullptr) &&
+  (I->base_addr == m_interpreter_base))
+continue;
+
   ModuleSP module_sp =
   LoadModuleAtAddress(I->file_spec, I->link_addr, I->base_addr, true);
   if (!module_sp.get())
@@ -450,15 +458,6 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() {
 } else if (module_sp == interpreter_sp) {
   // Module already loaded.
   continue;
-} else {
-  // If this is a duplicate instance of ld.so, unload it.  We may end
-  // up with it if we load it via a different path than before
-  // (symlink vs real path).
-  // TODO: remove this once we either fix library matching or avoid
-  // loading the interpreter when setting the rendezvous breakpoint.
-  UnloadSections(module_sp);
-  loaded_modules.Remove(module_sp);
-  continue;
 }
   }
 

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


[Lldb-commits] [lldb] [mlir] Verify TestBuiltinAttributeInterfaces eltype (PR #69878)

2023-10-23 Thread Rik Huijzer via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Check for duplicate interpreter modules without loading them (PR #69932)

2023-10-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

Fixes #68987

Early on we load the interpreter (most commonly ld-linux) in 
LoadInterpreterModule. Then later when we get the first DYLD rendezvous we get 
a list of libraries that commonly includes ld-linux again.

Previously we would load this duplicate, see that it was a duplicate, and 
unload it.

Problem was that this unloaded the section information of the first copy of 
ld-linux. On platforms where you can place a breakpoint using only an address, 
this wasn't an issue.

On ARM you have ARM and Thumb modes. We must know which one the section we're 
breaking in is, otherwise we'll go there in the wrong mode and SIGILL. This 
happened on ARM when lldb tried to call mmap during expression evaluation.

To fix this, I am making the assumption that the base address we see in the 
module prior to loading can be compared with what we know the interpreter base 
address is. Then we don't have to load the module to know we can ignore it.

This fixes the lldb test suite on Ubuntu versions where 
https://bugs.launchpad.net/ubuntu/+source/gdb/+bug/1927192 has been fixed. 
Which was recently done on Jammy.

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


1 Files Affected:

- (modified) 
lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp (+8-9) 


``diff
diff --git 
a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp 
b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
index c427b476089e458..3d65f496742099d 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp
@@ -437,6 +437,14 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() {
   m_initial_modules_added = true;
 }
 for (; I != E; ++I) {
+  // Don't load a duplicate copy of ld.so if we have already loaded it
+  // earlier in LoadInterpreterModule. If we instead loaded then unloaded 
it
+  // later, the section information for ld.so would be removed. That
+  // information is required for placing breakpoints on Arm/Thumb systems.
+  if ((m_interpreter_module.lock() != nullptr) &&
+  (I->base_addr == m_interpreter_base))
+continue;
+
   ModuleSP module_sp =
   LoadModuleAtAddress(I->file_spec, I->link_addr, I->base_addr, true);
   if (!module_sp.get())
@@ -450,15 +458,6 @@ void DynamicLoaderPOSIXDYLD::RefreshModules() {
 } else if (module_sp == interpreter_sp) {
   // Module already loaded.
   continue;
-} else {
-  // If this is a duplicate instance of ld.so, unload it.  We may end
-  // up with it if we load it via a different path than before
-  // (symlink vs real path).
-  // TODO: remove this once we either fix library matching or avoid
-  // loading the interpreter when setting the rendezvous breakpoint.
-  UnloadSections(module_sp);
-  loaded_modules.Remove(module_sp);
-  continue;
 }
   }
 

``




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


[Lldb-commits] [lldb] [lldb] Check for duplicate interpreter modules without loading them (PR #69932)

2023-10-23 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Following the code down into `ObjectFileELF::SetLoadAddress` for ELF, I don't 
see the value we get from `I->base_addr` being any different from the one we 
get later as `module_sp->GetObjectFile()->GetBaseAddress().GetLoadAddress`. We 
set `value_is_offset` to true, if it were false, then it could change and this 
assumption would not hold.

I've tested this on a few versions of Ubuntu across ARM, AArch64 and AMD64.

As this is the POSIX DYLD not just Linux, @emaste in case there's any FreeBSD 
details I need to account for.

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


[Lldb-commits] [lldb] [lldb] On POSIX, check for duplicate interpreter modules without loading them (PR #69932)

2023-10-23 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread Aaron Ballman via lldb-commits

AaronBallman wrote:

I'm not qualified to provide much of a review, but I'm in support of the 
change, thank you for the patch!

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


[Lldb-commits] [lldb] 7030623 - [lldb][docs] Add strace example to Debugging doc

2023-10-23 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-10-23T17:04:34+01:00
New Revision: 70306238cf3730fd7ef02170a1fdfa302676ac2b

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

LOG: [lldb][docs] Add strace example to Debugging doc

This has been very useful lately debugging remote
connections. In some cases it's probably better
than our own logging.

Added: 


Modified: 
lldb/docs/resources/debugging.rst

Removed: 




diff  --git a/lldb/docs/resources/debugging.rst 
b/lldb/docs/resources/debugging.rst
index 63c88477a848c43..990a95f54e07ff8 100644
--- a/lldb/docs/resources/debugging.rst
+++ b/lldb/docs/resources/debugging.rst
@@ -213,11 +213,26 @@ child processes.
 The same goes for ``printf``. If it's called in a child process you won't see
 the output.
 
-In these cases consider either interactive debugging ``lldb-server`` or
+In these cases consider interactive debugging ``lldb-server`` or
 working out a more specific command such that it does not have to spawn a
 subprocess. For example if you start with ``platform`` mode, work out what
 ``gdbserver`` mode process it spawns and run that command instead.
 
+Another option if you have ``strace`` available is to trace the whole process
+tree and inspect the logs after the session has ended. ::
+
+  $ strace -ff -o log -p $(pidof lldb-server)
+
+This will log all syscalls made by ``lldb-server`` and processes that it forks.
+``-ff`` tells ``strace`` to trace child processes and write the results to a
+separate file for each process, named using the prefix given by ``-o``.
+
+Search the log files for specific terms to find the process you're interested
+in. For example, to find a process that acted as a ``gdbserver`` instance::
+
+  $ grep "gdbserver" log.*
+  log.:execve("<...>/lldb-server", [<...> "gdbserver", <...>) = 0
+
 Remote Debugging
 
 



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


[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-23 Thread Aaron Ballman via lldb-commits


@@ -23,6 +23,7 @@
 
 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
 #define __STDC_VERSION_STDCKDINT_H__ 202311L
+#endif

AaronBallman wrote:

GCC exposes this value in all C and C++ language modes, so we should go ahead 
and remove the `#if` entirely and just always define the macro.

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


[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-23 Thread Aaron Ballman via lldb-commits


@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c2x %s

AaronBallman wrote:

This triple is the same as the one below (c2x and c23 are aliases), did you 
mean to use `-std=c11` or something along those lines?

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


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-23 Thread Med Ismail Bennani via lldb-commits


@@ -0,0 +1,140 @@
+//===-- WatchpointResource.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+
+#include "lldb/Breakpoint/WatchpointCollection.h"
+#include "lldb/lldb-public.h"
+
+#include 
+
+namespace lldb_private {
+
+class WatchpointResource
+: public std::enable_shared_from_this {
+
+public:
+  // Constructors and Destructors
+  WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write);
+
+  ~WatchpointResource();
+
+  void GetMemoryRange(lldb::addr_t &addr, size_t &size) const;
+
+  lldb::addr_t GetAddress() const;
+
+  size_t GetByteSize() const;
+
+  void GetType(bool &read, bool &write) const;
+
+  void SetType(bool read, bool write);
+
+  /// The "Owners" are the watchpoints that share this resource.
+  /// The method adds the \a owner to this resource's owner list.
+  ///
+  /// \param[in] owner
+  ///\a owner is the Wachpoint to add.
+  void AddOwner(const lldb::WatchpointSP &owner);
+
+  /// The method removes the owner at \a owner from this watchpoint
+  /// resource.
+  void RemoveOwner(lldb::WatchpointSP &owner);
+
+  /// This method returns the number of Watchpoints currently using
+  /// watchpoint resource.
+  ///
+  /// \return
+  ///The number of owners.
+  size_t GetNumberOfOwners();
+
+  /// This method returns the Watchpoint at index \a index using this
+  /// Resource.  The owners are listed ordinally from 0 to
+  /// GetNumberOfOwners() - 1 so you can use this method to iterate over the
+  /// owners.
+  ///
+  /// \param[in] idx
+  /// The index in the list of owners for which you wish the owner 
location.
+  ///
+  /// \return
+  ///The Watchpoint at that index.
+  lldb::WatchpointSP GetOwnerAtIndex(size_t idx);
+
+  /// Check if the owners includes a watchpoint.
+  ///
+  /// \param[in] wp_sp
+  /// The WatchpointSP to search for.
+  ///
+  /// \result
+  /// true if this resource's owners includes the watchpoint.
+  bool OwnersContains(lldb::WatchpointSP &wp_sp);
+
+  /// Check if the owners includes a watchpoint.
+  ///
+  /// \param[in] wp
+  /// The Watchpoint to search for.
+  ///
+  /// \result
+  /// true if this resource's owners includes the watchpoint.
+  bool OwnersContains(const lldb_private::Watchpoint *wp);
+
+  /// This method copies the watchpoint resource's owners into a new 
collection.
+  /// It does this while the owners mutex is locked.
+  ///
+  /// \param[out] out_collection
+  ///The BreakpointLocationCollection into which to put the owners
+  ///of this breakpoint site.
+  ///
+  /// \return
+  ///The number of elements copied into out_collection.
+  size_t CopyOwnersList(WatchpointCollection &out_collection);
+
+  // The ID of the WatchpointResource is set by the WatchpointResourceList
+  // when the Resource has been set in the inferior and is being added
+  // to the List, in an attempt to match the hardware watchpoint register
+  // ordering.  If a Process can correctly identify the hardware watchpoint
+  // register index when it has created the Resource, it may initialize it
+  // before it is inserted in the WatchpointResourceList.
+  void SetID(lldb::wp_resource_id_t);

medismailben wrote:

IIUC, this ID shouldn't change during the `Resource`'s lifetime so why not set 
it once in the constructor, and get rid of this setter ?

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


[Lldb-commits] [lldb] 77374d3 - [lldb] Move ScriptInterpreter Interfaces to subdirectory (NFC)

2023-10-23 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-10-23T09:51:01-07:00
New Revision: 77374d3b53cee7829ba70b13abf33e0d63d9d256

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

LOG: [lldb] Move ScriptInterpreter Interfaces to subdirectory (NFC)

As we're consolidating and  streamlining the various scripting
affordances of lldb, we keep creating new interface files.

This patch groups all the current interface files into a separate sub
directory called `Interfaces` both in the core `Interpreter` directory
and the `ScriptInterpreter` plugin directory.

Differential Revision: https://reviews.llvm.org/D158833

Signed-off-by: Med Ismail Bennani 

Added: 
lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.h

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.h

Modified: 
lldb/include/lldb/Interpreter/ScriptInterpreter.h
lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h

Removed: 
lldb/include/lldb/Interpreter/ScriptedInterface.h
lldb/include/lldb/Interpreter/ScriptedPlatformInterface.h
lldb/include/lldb/Interpreter/ScriptedProcessInterface.h

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.h

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h

lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h



diff  --git a/lldb/include/lldb/Interpreter/ScriptedInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
similarity index 93%
rename from lldb/include/lldb/Interpreter/ScriptedInterface.h
rename to lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
index ab6142593264374..948f763e95ecea4 100644
--- a/lldb/include/lldb/Interpreter/ScriptedInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
@@ -6,8 +6,8 @@
 //
 
//===--===//
 
-#ifndef LLDB_INTERPRETER_SCRIPTEDINTERFACE_H
-#define LLDB_INTERPRETER_SCRIPTEDINTERFACE_H
+#ifndef LLDB_INTERPRETER_INTERFACES_SCRIPTEDINTERFACE_H
+#define LLDB_INTERPRETER_INTERFACES_SCRIPTEDINTERFACE_H
 
 #include "lldb/Core/StructuredDataImpl.h"
 #include "lldb/Target/ExecutionContext.h"
@@ -74,4 +74,4 @@ class ScriptedInterface {
   StructuredData::GenericSP m_object_instance_sp;
 };
 } // namespace lldb_private
-#endif // LLDB_INTERPRETER_SCRIPTEDINTERFACE_H
+#endif // LLDB_INTERPRETER_INTERFACES_SCRIPTEDINTERFACE_H

diff  --git a/lldb/include/lldb/Interpreter/ScriptedPlatformInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
similarity index 85%
rename from lldb/include/lldb/Interpreter/ScriptedPlatformInterface.h
rename to lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
index 2db1fef0be721e6..c687cabfe0c1278 100644
--- a/lldb/include/lldb/Interpreter/ScriptedPlatformInterface.h
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
@@ -6,11 +6,11 @@
 //
 
//===--===//
 
-#ifndef LLDB_INTERPRETER_SCRIPTEDPLATFORMINTERFACE_H
-#define LLDB_INTERPRETER_SCRIPTEDPLATFORMINTERFACE_H
+#ifndef LLDB_INTERPRETER_INTERFACES_SCRIPTEDPLATFORMINTERFACE_H
+#define LLDB_INTERPRETER_INTERFAC

[Lldb-commits] [lldb] 6bff2d5 - [lldb] Move template python files to separate directory

2023-10-23 Thread Med Ismail Bennani via lldb-commits

Author: Med Ismail Bennani
Date: 2023-10-23T09:51:25-07:00
New Revision: 6bff2d51dcc7a369ba82fd44faa9eb207c621267

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

LOG: [lldb] Move template python files to separate directory

This patch moves the template files for the various scripting
affordances to a separate directory.

This is a preparatory work for upcoming improvements and consolidations
to other scripting affordances.

Differential Revision: https://reviews.llvm.org/D159310

Signed-off-by: Med Ismail Bennani 

Added: 
lldb/examples/python/crashlog_scripted_process.py
lldb/examples/python/templates/scripted_platform.py
lldb/examples/python/templates/scripted_process.py

Modified: 
lldb/bindings/python/CMakeLists.txt

Removed: 
lldb/examples/python/scripted_process/crashlog_scripted_process.py
lldb/examples/python/scripted_process/scripted_platform.py
lldb/examples/python/scripted_process/scripted_process.py



diff  --git a/lldb/bindings/python/CMakeLists.txt 
b/lldb/bindings/python/CMakeLists.txt
index 2cc3ad1bb98b73e..c4806bda27049c6 100644
--- a/lldb/bindings/python/CMakeLists.txt
+++ b/lldb/bindings/python/CMakeLists.txt
@@ -103,15 +103,15 @@ function(finish_swig_python swig_target 
lldb_python_bindings_dir lldb_python_tar
 ${lldb_python_target_dir}
 "plugins"
 FILES
-"${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_process.py"
-"${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_platform.py")
+"${LLDB_SOURCE_DIR}/examples/python/templates/scripted_process.py"
+"${LLDB_SOURCE_DIR}/examples/python/templates/scripted_platform.py")
 
   if(APPLE)
 create_python_package(
   ${swig_target}
   ${lldb_python_target_dir} "macosx"
   FILES "${LLDB_SOURCE_DIR}/examples/python/crashlog.py"
-
"${LLDB_SOURCE_DIR}/examples/python/scripted_process/crashlog_scripted_process.py"
+"${LLDB_SOURCE_DIR}/examples/python/crashlog_scripted_process.py"
 "${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap.py")
 
 create_python_package(

diff  --git 
a/lldb/examples/python/scripted_process/crashlog_scripted_process.py 
b/lldb/examples/python/crashlog_scripted_process.py
similarity index 100%
rename from lldb/examples/python/scripted_process/crashlog_scripted_process.py
rename to lldb/examples/python/crashlog_scripted_process.py

diff  --git a/lldb/examples/python/scripted_process/scripted_platform.py 
b/lldb/examples/python/templates/scripted_platform.py
similarity index 100%
rename from lldb/examples/python/scripted_process/scripted_platform.py
rename to lldb/examples/python/templates/scripted_platform.py

diff  --git a/lldb/examples/python/scripted_process/scripted_process.py 
b/lldb/examples/python/templates/scripted_process.py
similarity index 100%
rename from lldb/examples/python/scripted_process/scripted_process.py
rename to lldb/examples/python/templates/scripted_process.py



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


[Lldb-commits] [PATCH] D158833: [lldb] Move ScriptInterpreter Interfaces to subdirectory (NFC)

2023-10-23 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG77374d3b53ce: [lldb] Move ScriptInterpreter Interfaces to 
subdirectory (NFC) (authored by mib).

Changed prior to commit:
  https://reviews.llvm.org/D158833?vs=554991&id=557844#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158833/new/

https://reviews.llvm.org/D158833

Files:
  lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h
  lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h
  lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h
  lldb/include/lldb/Interpreter/Interfaces/ScriptedThreadInterface.h
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/include/lldb/Interpreter/ScriptedInterface.h
  lldb/include/lldb/Interpreter/ScriptedPlatformInterface.h
  lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
  lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt
  
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.cpp
  
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface.h
  
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.cpp
  
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface.h
  
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
  
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
  
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.cpp
  
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPlatformPythonInterface.h
  
lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedProcessPythonInterface.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedPythonInterface.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptedThreadPythonInterface.h

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -140,6 +140,7 @@
 
   StructuredData::DictionarySP
   OSPlugin_RegisterInfo(StructuredData::ObjectSP os_plugin_object_sp) override;
+  lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() override;
 
   StructuredData::ArraySP
   OSPlugin_ThreadsInfo(StructuredData::ObjectSP os_plugin_object_sp) override;
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -14,12 +14,13 @@
 // LLDB Python header must be included first
 #include "lldb-python.h"
 
+#include "Interfaces/ScriptedPlatformPythonInterface.h"
+#include "Interfaces/ScriptedProcessPythonInterface.h"
+#include "Interfaces/ScriptedThreadPythonInterface.h"
 #include "PythonDataObjects.h"
 #include "PythonReadline.h"
 #include "SWIGPythonBridge.h"
 #include "ScriptInterpreterPythonImpl.h"
-#include "ScriptedPlatformPythonInterface.h"
-#include "ScriptedProcessPythonInterface.h"
 
 #include "lldb/API/SBError.h"
 #include "lldb/API/SBFrame.h"
@@ -1515,6 +1516,11 @@
   return std::make_unique(*this);
 }
 
+ScriptedThreadInterfaceSP
+ScriptInterpreterPythonImpl::CreateScriptedThreadInterface() {
+  return std::make_shared(*this);
+}
+
 StructuredData::ObjectSP
 ScriptInterpreterPythonImpl::CreateStructuredDataFromScriptObject(
 ScriptObject obj) {
Index: lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPythonInterface.h
@@ -6,15 +6,15 @@
 //
 //===--===//
 
-#ifndef LLDB_PLUGINS_SCRIPTINTERPRETER_PYTHON_SCRIPTEDTHREADPYTHONINTERFACE_H
-#define LLDB_PLUGINS_SCRIPTINTERPRETER_PYT

[Lldb-commits] [PATCH] D159310: [lldb] Move template python files to separate directory

2023-10-23 Thread Med Ismail Bennani via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6bff2d51dcc7: [lldb] Move template python files to separate 
directory (authored by mib).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159310/new/

https://reviews.llvm.org/D159310

Files:
  lldb/bindings/python/CMakeLists.txt
  lldb/examples/python/crashlog_scripted_process.py
  lldb/examples/python/scripted_process/crashlog_scripted_process.py
  lldb/examples/python/scripted_process/scripted_platform.py
  lldb/examples/python/scripted_process/scripted_process.py
  lldb/examples/python/templates/scripted_platform.py
  lldb/examples/python/templates/scripted_process.py


Index: lldb/bindings/python/CMakeLists.txt
===
--- lldb/bindings/python/CMakeLists.txt
+++ lldb/bindings/python/CMakeLists.txt
@@ -103,15 +103,15 @@
 ${lldb_python_target_dir}
 "plugins"
 FILES
-"${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_process.py"
-"${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_platform.py")
+"${LLDB_SOURCE_DIR}/examples/python/templates/scripted_process.py"
+"${LLDB_SOURCE_DIR}/examples/python/templates/scripted_platform.py")
 
   if(APPLE)
 create_python_package(
   ${swig_target}
   ${lldb_python_target_dir} "macosx"
   FILES "${LLDB_SOURCE_DIR}/examples/python/crashlog.py"
-
"${LLDB_SOURCE_DIR}/examples/python/scripted_process/crashlog_scripted_process.py"
+"${LLDB_SOURCE_DIR}/examples/python/crashlog_scripted_process.py"
 "${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap.py")
 
 create_python_package(


Index: lldb/bindings/python/CMakeLists.txt
===
--- lldb/bindings/python/CMakeLists.txt
+++ lldb/bindings/python/CMakeLists.txt
@@ -103,15 +103,15 @@
 ${lldb_python_target_dir}
 "plugins"
 FILES
-"${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_process.py"
-"${LLDB_SOURCE_DIR}/examples/python/scripted_process/scripted_platform.py")
+"${LLDB_SOURCE_DIR}/examples/python/templates/scripted_process.py"
+"${LLDB_SOURCE_DIR}/examples/python/templates/scripted_platform.py")
 
   if(APPLE)
 create_python_package(
   ${swig_target}
   ${lldb_python_target_dir} "macosx"
   FILES "${LLDB_SOURCE_DIR}/examples/python/crashlog.py"
-"${LLDB_SOURCE_DIR}/examples/python/scripted_process/crashlog_scripted_process.py"
+"${LLDB_SOURCE_DIR}/examples/python/crashlog_scripted_process.py"
 "${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap.py")
 
 create_python_package(
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Add a single bit constructor for RegisterFlags::Field (PR #69315)

2023-10-23 Thread Alex Langford via lldb-commits

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

Sorry for the delay, this looks fine to me. I don't have much to say about your 
RFC (since it's not something I have a lot of expertise on) but I look forward 
to seeing it get implemented! 😄 

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


[Lldb-commits] [lldb] [lldb][docs] Update contributing links (PR #69726)

2023-10-23 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] fe92977 - [lldb] Add a single bit constructor for RegisterFlags::Field (#69315)

2023-10-23 Thread via lldb-commits

Author: David Spickett
Date: 2023-10-23T18:16:03+01:00
New Revision: fe929770f41e7b962ebaaeb0a3a3b03f8b8c

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

LOG: [lldb] Add a single bit constructor for RegisterFlags::Field (#69315)

This means you don't have to do RegisterField("", 0, 0), you can do
RegisterField("", 0).

Which is useful for testing and even more useful when we are writing
definitions of real registers which have 10s of single bit fields.

Added: 


Modified: 
lldb/include/lldb/Target/RegisterFlags.h
lldb/unittests/Target/RegisterFlagsTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/RegisterFlags.h 
b/lldb/include/lldb/Target/RegisterFlags.h
index 8137fd27e99c2a2..d98bc0263e35e23 100644
--- a/lldb/include/lldb/Target/RegisterFlags.h
+++ b/lldb/include/lldb/Target/RegisterFlags.h
@@ -17,11 +17,17 @@ class RegisterFlags {
 public:
   class Field {
   public:
+/// Where start is the least significant bit and end is the most
+/// significant bit. The start bit must be <= the end bit.
 Field(std::string name, unsigned start, unsigned end)
 : m_name(std::move(name)), m_start(start), m_end(end) {
   assert(m_start <= m_end && "Start bit must be <= end bit.");
 }
 
+/// Construct a field that occupies a single bit.
+Field(std::string name, unsigned bit_position)
+: m_name(std::move(name)), m_start(bit_position), m_end(bit_position) 
{}
+
 /// Get size of the field in bits. Will always be at least 1.
 unsigned GetSizeInBits() const { return m_end - m_start + 1; }
 

diff  --git a/lldb/unittests/Target/RegisterFlagsTest.cpp 
b/lldb/unittests/Target/RegisterFlagsTest.cpp
index 194e05959c16599..167e28d0cecb3bd 100644
--- a/lldb/unittests/Target/RegisterFlagsTest.cpp
+++ b/lldb/unittests/Target/RegisterFlagsTest.cpp
@@ -16,7 +16,7 @@ using namespace lldb;
 TEST(RegisterFlagsTest, Field) {
   // We assume that start <= end is always true, so that is not tested here.
 
-  RegisterFlags::Field f1("abc", 0, 0);
+  RegisterFlags::Field f1("abc", 0);
   ASSERT_EQ(f1.GetName(), "abc");
   // start == end means a 1 bit field.
   ASSERT_EQ(f1.GetSizeInBits(), (unsigned)1);
@@ -51,11 +51,15 @@ static RegisterFlags::Field make_field(unsigned start, 
unsigned end) {
   return RegisterFlags::Field("", start, end);
 }
 
+static RegisterFlags::Field make_field(unsigned bit) {
+  return RegisterFlags::Field("", bit);
+}
+
 TEST(RegisterFlagsTest, FieldOverlaps) {
   // Single bit fields
-  ASSERT_FALSE(make_field(0, 0).Overlaps(make_field(1, 1)));
-  ASSERT_TRUE(make_field(1, 1).Overlaps(make_field(1, 1)));
-  ASSERT_FALSE(make_field(1, 1).Overlaps(make_field(3, 3)));
+  ASSERT_FALSE(make_field(0, 0).Overlaps(make_field(1)));
+  ASSERT_TRUE(make_field(1, 1).Overlaps(make_field(1)));
+  ASSERT_FALSE(make_field(1, 1).Overlaps(make_field(3)));
 
   ASSERT_TRUE(make_field(0, 1).Overlaps(make_field(1, 2)));
   ASSERT_TRUE(make_field(1, 2).Overlaps(make_field(0, 1)));
@@ -71,13 +75,13 @@ TEST(RegisterFlagsTest, PaddingDistance) {
   // (start bit is higher) field first and that they do not overlap.
 
   // [field 1][field 2]
-  ASSERT_EQ(make_field(1, 1).PaddingDistance(make_field(0, 0)), 0ULL);
+  ASSERT_EQ(make_field(1, 1).PaddingDistance(make_field(0)), 0ULL);
   // [field 1][..][field 2]
-  ASSERT_EQ(make_field(2, 2).PaddingDistance(make_field(0, 0)), 1ULL);
+  ASSERT_EQ(make_field(2, 2).PaddingDistance(make_field(0)), 1ULL);
   // [field 1][field 1][field 2]
-  ASSERT_EQ(make_field(1, 2).PaddingDistance(make_field(0, 0)), 0ULL);
+  ASSERT_EQ(make_field(1, 2).PaddingDistance(make_field(0)), 0ULL);
   // [field 1][30 bits free][field 2]
-  ASSERT_EQ(make_field(31, 31).PaddingDistance(make_field(0, 0)), 30ULL);
+  ASSERT_EQ(make_field(31, 31).PaddingDistance(make_field(0)), 30ULL);
 }
 
 static void test_padding(const std::vector &fields,
@@ -99,18 +103,18 @@ TEST(RegisterFlagsTest, RegisterFlagsPadding) {
 
   // Needs padding in between the fields, single bit.
   test_padding({make_field(17, 31), make_field(0, 15)},
-   {make_field(17, 31), make_field(16, 16), make_field(0, 15)});
+   {make_field(17, 31), make_field(16), make_field(0, 15)});
   // Multiple bits of padding.
   test_padding({make_field(17, 31), make_field(0, 14)},
{make_field(17, 31), make_field(15, 16), make_field(0, 14)});
 
   // Padding before first field, single bit.
-  test_padding({make_field(0, 30)}, {make_field(31, 31), make_field(0, 30)});
+  test_padding({make_field(0, 30)}, {make_field(31), make_field(0, 30)});
   // Multiple bits.
   test_padding({make_field(0, 15)}, {make_field(16, 31), make_field(0, 15)});
 
   // Padding after last field, single bit.
-  test_padding({make_field(1, 31)}, {make_field(1

[Lldb-commits] [lldb] [lldb] Add a single bit constructor for RegisterFlags::Field (PR #69315)

2023-10-23 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] aab0626 - [lldb][docs] Update contributing links (#69726)

2023-10-23 Thread via lldb-commits

Author: David Spickett
Date: 2023-10-23T18:20:27+01:00
New Revision: aab0626c2e3e8ffedcb69dd2c73a4c9fe0e2aca4

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

LOG: [lldb][docs] Update contributing links (#69726)

Patches now go to PRs, mention the Discord server as well as the forum.

Added: 


Modified: 
lldb/docs/index.rst

Removed: 




diff  --git a/lldb/docs/index.rst b/lldb/docs/index.rst
index 2fff25b27b974ea..88ed245b7b27472 100644
--- a/lldb/docs/index.rst
+++ b/lldb/docs/index.rst
@@ -102,10 +102,13 @@ Additionally it builds:
 See the :doc:`LLDB Build Page ` for build instructions.
 
 Discussions about LLDB should go to the `LLDB forum
-`__. Commit
+`__ or the ``lldb`` channel on
+the `LLVM Discord server `__.
+
+For contributions follow the
+`LLVM contribution process `__. Commit
 messages are automatically sent to the `lldb-commits
-`__ mailing list, and
-this is also the preferred mailing list for patch submissions.
+`__ mailing list.
 
 See the :doc:`Projects page ` if you are looking for some
 interesting areas to contribute to lldb.



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


[Lldb-commits] [lldb] [lldb][docs] Update contributing links (PR #69726)

2023-10-23 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-23 Thread via lldb-commits

jimingham wrote:

SymbolFiles can be owned by more than one debugger at a time.  That's actually 
a very common mode for GUI's that can host more than one debugging session at a 
time.  You can iterate over the list of debuggers from anywhere, and query the 
value of this property, but if two Debugger's disagree about the value, you 
won't have a way to figure out which one should win.

Jim


> On Oct 20, 2023, at 2:35 PM, Tom Yang ***@***.***> wrote:
> 
> 
> Because SymbolFile is holding onto the function pointer as a static member, 
> this is a global setting that you can't apply to only just one SBDebugger 
> object. It's an all-or-nothing thing. Maybe that's what you want, but LLDB 
> already has architectural issues with certain functionality being difficult 
> to detangle from global state (e.g. Logging). Maybe we could make it a 
> property of the Debugger instead?
> 
> That sounds good to me, though I didn't think there was a path to the 
> debugger from SymbolFileDWARF?
> 
> —
> Reply to this email directly, view it on GitHub 
> , or 
> unsubscribe 
> .
> You are receiving this because you are on a team that was mentioned.
> 



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


[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-23 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/69649

>From 0c57e45f6ee16e43cc6388b1ca6beb88bbc7b925 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 19 Oct 2023 22:23:03 +
Subject: [PATCH 1/3] Update stdckdint.h and make it available in pre-C23
 modes.

Update some tests and docs.
---
 clang/docs/ReleaseNotes.rst| 2 +-
 clang/lib/Headers/stdckdint.h  | 4 
 clang/test/C/C2x/n2359.c   | 5 -
 clang/test/C/C2x/n2683.c   | 1 +
 clang/test/C/C2x/n2683_2.c | 1 +
 clang/test/Headers/stdckdint.c | 7 +--
 6 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fc8caf9221b9d29..d0de52a5bf122f4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -177,7 +177,7 @@ C23 Feature Support
 - Clang now supports ``N3007 Type inference for object definitions``.
 
 - Clang now supports  which defines several macros for 
performing
-  checked integer arithmetic.
+  checked integer arithmetic. And it is also exposed in pre-C23 modes.
 
 Non-comprehensive list of changes in this release
 -
diff --git a/clang/lib/Headers/stdckdint.h b/clang/lib/Headers/stdckdint.h
index 22972d78d9077a4..77290b260ff3bd4 100644
--- a/clang/lib/Headers/stdckdint.h
+++ b/clang/lib/Headers/stdckdint.h
@@ -21,9 +21,6 @@
 
 /* C23 7.20.1 Defines several macros for performing checked integer 
arithmetic*/
 
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
-#define __STDC_VERSION_STDCKDINT_H__ 202311L
-
 // Both A and B shall be any integer type other than "plain" char, bool, a bit-
 // precise integer type, or an enumerated type, and they need not be the same.
 
@@ -38,7 +35,6 @@
 #define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))
 #define ckd_sub(R, A, B) __builtin_sub_overflow((A), (B), (R))
 #define ckd_mul(R, A, B) __builtin_mul_overflow((A), (B), (R))
-#endif
 
 #endif /* __STDC_HOSTED__ */
 #endif /* __STDCKDINT_H */
diff --git a/clang/test/C/C2x/n2359.c b/clang/test/C/C2x/n2359.c
index dc38bab43c9db8d..0a1b801e505e146 100644
--- a/clang/test/C/C2x/n2359.c
+++ b/clang/test/C/C2x/n2359.c
@@ -33,8 +33,3 @@
 #error "__STDC_VERSION_STDINT_H__ not defined"
 // expected-error@-1 {{"__STDC_VERSION_STDINT_H__ not defined"}}
 #endif
-
-#include 
-#ifndef __STDC_VERSION_STDCKDINT_H__
-#error "__STDC_VERSION_STDCKDINT_H__ not defined"
-#endif
diff --git a/clang/test/C/C2x/n2683.c b/clang/test/C/C2x/n2683.c
index 0c666c5fd8782ba..a785d46c063c2cc 100644
--- a/clang/test/C/C2x/n2683.c
+++ b/clang/test/C/C2x/n2683.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c2x %s
 // RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c23 %s
 
 /* WG14 N2683: Clang 18
diff --git a/clang/test/C/C2x/n2683_2.c b/clang/test/C/C2x/n2683_2.c
index 247f6de8fe4bfe1..867d6b876cf0d9d 100644
--- a/clang/test/C/C2x/n2683_2.c
+++ b/clang/test/C/C2x/n2683_2.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -o - -std=c2x %s | FileCheck %s
 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -o - -std=c23 %s | FileCheck %s
 
 #include 
diff --git a/clang/test/Headers/stdckdint.c b/clang/test/Headers/stdckdint.c
index 896c740360065b6..7774cecfa7c3317 100644
--- a/clang/test/Headers/stdckdint.c
+++ b/clang/test/Headers/stdckdint.c
@@ -1,12 +1,15 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c99 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c11 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c17 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c2x %s -o - | 
FileCheck %s
 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c23 %s -o - | 
FileCheck %s
 
 // expected-no-diagnostics
 
+#include 
 #include 
 
-_Static_assert(__STDC_VERSION_STDCKDINT_H__ == 202311L, "");
-
 // CHECK-LABEL: define dso_local zeroext i1 @test_ckd_add(
 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:

>From 4e2fd920121b15e014a6146c6c6672973bae4443 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 19 Oct 2023 22:23:03 +
Subject: [PATCH 2/3] Update stdckdint.h and make it available in pre-C23
 modes.

Update some tests and docs.
---
 clang/docs/ReleaseNotes.rst   | 2 +-
 clang/lib/Headers/stdckdint.h | 4 
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d0de52a5bf122f4..1b1f25ae244ef9f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -177,7 +177,7 @@ C23 Feature Support
 - Clang 

[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending registerflags as XML (PR #69951)

2023-10-23 Thread David Spickett via lldb-commits

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

This adds ToXML methods to encode RegisterFlags and its fields into XML 
according to GDB's target XML format:
https://sourceware.org/gdb/onlinedocs/gdb/Target-Description-Format.html#Target-Description-Format

lldb-server does not currently use libXML to build XML, so this follows the 
existing code that uses strings. Indentation is used so the result is still 
human readable.

```

  

```

This is used by lldb-server when building target XML, though no one sets any 
fields yet. That'll come in a later commit.

>From 5c8b9538e1e5646f19d5bb40ab19afaf2c68e804 Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 9 Oct 2023 10:33:08 +0100
Subject: [PATCH] [lldb][lldb-server] Enable sending registerflags as XML

This adds ToXML methods to encode RegisterFlags and its fields
into XML according to GDB's target XML format:
https://sourceware.org/gdb/onlinedocs/gdb/Target-Description-Format.html#Target-Description-Format

lldb-server does not currently use libXML to build XML,
so this follows the existing code that uses strings. Indentation
is used so the result is still human readable.

```

  

```

This is used by lldb-server when building target XML,
though no one sets any fields yet. That'll come in a later commit.
---
 lldb/include/lldb/Target/RegisterFlags.h  |  8 +
 .../GDBRemoteCommunicationServerLLGS.cpp  | 10 ++
 lldb/source/Target/RegisterFlags.cpp  | 32 +++
 lldb/unittests/Target/RegisterFlagsTest.cpp   | 32 +++
 4 files changed, 82 insertions(+)

diff --git a/lldb/include/lldb/Target/RegisterFlags.h 
b/lldb/include/lldb/Target/RegisterFlags.h
index d98bc0263e35e23..4edbe7255f621e5 100644
--- a/lldb/include/lldb/Target/RegisterFlags.h
+++ b/lldb/include/lldb/Target/RegisterFlags.h
@@ -10,6 +10,7 @@
 #define LLDB_TARGET_REGISTERFLAGS_H
 
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
 
 namespace lldb_private {
 
@@ -51,6 +52,10 @@ class RegisterFlags {
 /// covered by either field.
 unsigned PaddingDistance(const Field &other) const;
 
+/// Output XML that describes this field, to be inserted into a target XML
+/// file.
+void ToXML(StreamString &strm) const;
+
 bool operator<(const Field &rhs) const {
   return GetStart() < rhs.GetStart();
 }
@@ -106,6 +111,9 @@ class RegisterFlags {
   /// be split into many tables as needed.
   std::string AsTable(uint32_t max_width) const;
 
+  // Output XML that describes this set of flags.
+  void ToXML(StreamString &strm) const;
+
 private:
   const std::string m_id;
   /// Size in bytes
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 23c2f18cd388a86..1a4d561146c3bfb 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -3094,6 +3094,12 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() {
   continue;
 }
 
+if (reg_info->flags_type) {
+  response.IndentMore();
+  reg_info->flags_type->ToXML(response);
+  response.IndentLess();
+}
+
 response.Indent();
 response.Printf("flags_type) {
+  response << "type=\"" << reg_info->flags_type->GetID() << "\" ";
+}
+
 const char *const register_set_name =
 reg_context.GetRegisterSetNameForRegisterAtIndex(reg_index);
 if (register_set_name)
diff --git a/lldb/source/Target/RegisterFlags.cpp 
b/lldb/source/Target/RegisterFlags.cpp
index 06fb45d777ec36f..a0019d15a2088b2 100644
--- a/lldb/source/Target/RegisterFlags.cpp
+++ b/lldb/source/Target/RegisterFlags.cpp
@@ -175,3 +175,35 @@ std::string RegisterFlags::AsTable(uint32_t max_width) 
const {
 
   return table;
 }
+
+void RegisterFlags::ToXML(StreamString &strm) const {
+  // Example XML:
+  // 
+  //   
+  // 
+  strm.Indent();
+  strm << "";
+  for (const Field &field : m_fields) {
+// Skip padding fields.
+if (field.GetName().empty())
+  continue;
+
+strm << "\n";
+strm.IndentMore();
+field.ToXML(strm);
+strm.IndentLess();
+  }
+  strm.PutChar('\n');
+  strm.Indent("\n");
+}
+
+void RegisterFlags::Field::ToXML(StreamString &strm) const {
+  // Example XML:
+  // 
+  strm.Indent();
+  strm << "";
+}
diff --git a/lldb/unittests/Target/RegisterFlagsTest.cpp 
b/lldb/unittests/Target/RegisterFlagsTest.cpp
index 167e28d0cecb3bd..3b34e6b1e1c160c 100644
--- a/lldb/unittests/Target/RegisterFlagsTest.cpp
+++ b/lldb/unittests/Target/RegisterFlagsTest.cpp
@@ -258,3 +258,35 @@ TEST(RegisterFlagsTest, AsTable) {
 "| really long name |",
 max_many_columns.AsTable(23));
 }
+
+TEST(RegisterFieldsTest, ToXML) {
+  StreamString strm;
+
+  // RegisterFlags requires that some fields be given, so no testing of empty
+  // input.
+

[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-23 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-23 Thread David Spickett via lldb-commits

DavidSpickett wrote:

For 
https://discourse.llvm.org/t/rfc-adding-register-field-information-to-lldb-server/74143.

May be helpful to look at 
https://github.com/DavidSpickett/llvm-project/commit/93bdc630f6a4d27c4849b756838c5d70d23e2e90
 which will be the next PR and adds the first register information using this.

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


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

This adds ToXML methods to encode RegisterFlags and its fields into XML 
according to GDB's target XML format:
https://sourceware.org/gdb/onlinedocs/gdb/Target-Description-Format.html#Target-Description-Format

lldb-server does not currently use libXML to build XML, so this follows the 
existing code that uses strings. Indentation is used so the result is still 
human readable.

```

  

```

This is used by lldb-server when building target XML, though no one sets any 
fields yet. That'll come in a later commit.

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


4 Files Affected:

- (modified) lldb/include/lldb/Target/RegisterFlags.h (+8) 
- (modified) 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
(+10) 
- (modified) lldb/source/Target/RegisterFlags.cpp (+32) 
- (modified) lldb/unittests/Target/RegisterFlagsTest.cpp (+32) 


``diff
diff --git a/lldb/include/lldb/Target/RegisterFlags.h 
b/lldb/include/lldb/Target/RegisterFlags.h
index d98bc0263e35e23..4edbe7255f621e5 100644
--- a/lldb/include/lldb/Target/RegisterFlags.h
+++ b/lldb/include/lldb/Target/RegisterFlags.h
@@ -10,6 +10,7 @@
 #define LLDB_TARGET_REGISTERFLAGS_H
 
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"
 
 namespace lldb_private {
 
@@ -51,6 +52,10 @@ class RegisterFlags {
 /// covered by either field.
 unsigned PaddingDistance(const Field &other) const;
 
+/// Output XML that describes this field, to be inserted into a target XML
+/// file.
+void ToXML(StreamString &strm) const;
+
 bool operator<(const Field &rhs) const {
   return GetStart() < rhs.GetStart();
 }
@@ -106,6 +111,9 @@ class RegisterFlags {
   /// be split into many tables as needed.
   std::string AsTable(uint32_t max_width) const;
 
+  // Output XML that describes this set of flags.
+  void ToXML(StreamString &strm) const;
+
 private:
   const std::string m_id;
   /// Size in bytes
diff --git 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
index 23c2f18cd388a86..1a4d561146c3bfb 100644
--- 
a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
+++ 
b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
@@ -3094,6 +3094,12 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() {
   continue;
 }
 
+if (reg_info->flags_type) {
+  response.IndentMore();
+  reg_info->flags_type->ToXML(response);
+  response.IndentLess();
+}
+
 response.Indent();
 response.Printf("flags_type) {
+  response << "type=\"" << reg_info->flags_type->GetID() << "\" ";
+}
+
 const char *const register_set_name =
 reg_context.GetRegisterSetNameForRegisterAtIndex(reg_index);
 if (register_set_name)
diff --git a/lldb/source/Target/RegisterFlags.cpp 
b/lldb/source/Target/RegisterFlags.cpp
index 06fb45d777ec36f..a0019d15a2088b2 100644
--- a/lldb/source/Target/RegisterFlags.cpp
+++ b/lldb/source/Target/RegisterFlags.cpp
@@ -175,3 +175,35 @@ std::string RegisterFlags::AsTable(uint32_t max_width) 
const {
 
   return table;
 }
+
+void RegisterFlags::ToXML(StreamString &strm) const {
+  // Example XML:
+  // 
+  //   
+  // 
+  strm.Indent();
+  strm << "";
+  for (const Field &field : m_fields) {
+// Skip padding fields.
+if (field.GetName().empty())
+  continue;
+
+strm << "\n";
+strm.IndentMore();
+field.ToXML(strm);
+strm.IndentLess();
+  }
+  strm.PutChar('\n');
+  strm.Indent("\n");
+}
+
+void RegisterFlags::Field::ToXML(StreamString &strm) const {
+  // Example XML:
+  // 
+  strm.Indent();
+  strm << "";
+}
diff --git a/lldb/unittests/Target/RegisterFlagsTest.cpp 
b/lldb/unittests/Target/RegisterFlagsTest.cpp
index 167e28d0cecb3bd..3b34e6b1e1c160c 100644
--- a/lldb/unittests/Target/RegisterFlagsTest.cpp
+++ b/lldb/unittests/Target/RegisterFlagsTest.cpp
@@ -258,3 +258,35 @@ TEST(RegisterFlagsTest, AsTable) {
 "| really long name |",
 max_many_columns.AsTable(23));
 }
+
+TEST(RegisterFieldsTest, ToXML) {
+  StreamString strm;
+
+  // RegisterFlags requires that some fields be given, so no testing of empty
+  // input.
+
+  // Unnamed fields are padding that are ignored. This applies to fields passed
+  // in, and those generated to fill the other bits (31-1 here).
+  RegisterFlags("Foo", 4, {RegisterFlags::Field("", 0, 0)}).ToXML(strm);
+  ASSERT_EQ(strm.GetString(), "\n"
+  "\n");
+
+  strm.Clear();
+  RegisterFlags("Foo", 4, {RegisterFlags::Field("abc", 0, 0)}).ToXML(strm);
+  ASSERT_EQ(strm.GetString(), "\n"
+  "  \n"
+  "\n");
+
+  strm.Clear();
+  // Should use the current

[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-23 Thread David Spickett via lldb-commits

DavidSpickett wrote:

And if you're not familiar with lldb-server and XML, as I wasn't, it doesn't 
use libXML to generate it. That's why I'm building strings to fit with the 
existing target.xml code.

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


[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-23 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread Greg Clayton via lldb-commits

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

I am not sure about always showing the signed or unsigned value by default. 
Enum values by default get displayed as the string value if we can find it. If 
you want to see the value as signed or unsigned you can change the display 
format to decimal or unsigned. With this change, your value would appear to be 
`A(0)`, so if the user tried to edit this value, we don't want them typing 
`B(1)`, we just want them to type "B". 

I would be ok if we change the summary of an enum value to be the signed or 
unsigned value though. That might be a better option.

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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread Greg Clayton via lldb-commits

clayborg wrote:

To clarify a bit: each value (SBValue in our public API, and ValueObject in our 
private API) has the ability to supply a value string and a summary string. The 
value string can depend on what the current format is set to. For an enum 
value, the format defaults to `lldb::eFormatEnum`, but this can be changed to 
`lldb::eFormatHex`, `lldb::eFormatDecimal` or `lldb::eFormatUnsigned` and then 
the `const char *SBValue::GetValue()` would return an number instead of an 
enumeration. The summary of a value (`const char *SBValue::GetSummary()`) could 
changed for enum values to return the signed or unsigned value if desired. This 
will make the value always be correct and obey the format and the summary can 
always display the signed or unsigned value.

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


[Lldb-commits] [lldb] [LLDB] Update docs on building documentation (PR #69858)

2023-10-23 Thread Jonas Devlieghere via lldb-commits

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

LGTM with SWIG all caps. 

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


[Lldb-commits] [lldb] [LLDB] Update docs on building documentation (PR #69858)

2023-10-23 Thread Jonas Devlieghere via lldb-commits


@@ -403,13 +403,21 @@ dependencies are required:
 * Sphinx (for the website and the Python API reference)
 * Graphviz (for the 'dot' tool)
 * doxygen (if you wish to build the C++ API reference)
+* Swig (for generating Python bindings)

JDevlieghere wrote:

`s/Swig/SWIG/`

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


[Lldb-commits] [lldb] [LLDB] Update docs on building documentation (PR #69858)

2023-10-23 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb] On POSIX, check for duplicate interpreter modules without loading them (PR #69932)

2023-10-23 Thread Greg Clayton via lldb-commits

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

LGTM. I have seen multiple VSDO libraries being loaded sometimes too, but it 
doesn't use this path in the code, so this fix should work for ld.so

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


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-23 Thread Greg Clayton via lldb-commits


@@ -175,3 +175,35 @@ std::string RegisterFlags::AsTable(uint32_t max_width) 
const {
 
   return table;
 }
+
+void RegisterFlags::ToXML(StreamString &strm) const {
+  // Example XML:
+  // 
+  //   
+  // 
+  strm.Indent();
+  strm << "";
+  for (const Field &field : m_fields) {
+// Skip padding fields.
+if (field.GetName().empty())
+  continue;
+
+strm << "\n";
+strm.IndentMore();
+field.ToXML(strm);
+strm.IndentLess();
+  }
+  strm.PutChar('\n');
+  strm.Indent("\n");
+}
+
+void RegisterFlags::Field::ToXML(StreamString &strm) const {
+  // Example XML:
+  // 
+  strm.Indent();
+  strm << "https://github.com/llvm/llvm-project/pull/69951
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-23 Thread Greg Clayton via lldb-commits


@@ -3113,6 +3119,10 @@ GDBRemoteCommunicationServerLLGS::BuildTargetXml() {
 if (!format.empty())
   response << "format=\"" << format << "\" ";
 
+if (reg_info->flags_type) {
+  response << "type=\"" << reg_info->flags_type->GetID() << "\" ";
+}

clayborg wrote:

no braces for single statement `if` per llvm coding guidelines

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


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-23 Thread Greg Clayton via lldb-commits


@@ -10,6 +10,7 @@
 #define LLDB_TARGET_REGISTERFLAGS_H
 
 #include "lldb/Utility/Log.h"
+#include "lldb/Utility/StreamString.h"

clayborg wrote:

We can just forward declare StreamString, and possibly remove Log.h above as 
well if we want to.

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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread Aaron Ballman via lldb-commits

AaronBallman wrote:

Making sure I'm following along properly. For context, this is the debug 
experience I'm most used to:
![Capture](https://github.com/llvm/llvm-project/assets/4587626/e45937dc-9b78-4a3d-9321-1fa99a35daa8)

It sounds like you're saying we shouldn't change the enum formatter to display 
`Enum (1)`, it should continue to display just `Enum`. But the summary could be 
changed for enumerations so it says `(1)`, so that both pieces of information 
would appear in the debugger by default?

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


[Lldb-commits] [lldb] Update stdckdint.h and make it available in pre-C23 modes. (PR #69649)

2023-10-23 Thread via lldb-commits

https://github.com/ZijunZhaoCCK updated 
https://github.com/llvm/llvm-project/pull/69649

>From 0c57e45f6ee16e43cc6388b1ca6beb88bbc7b925 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 19 Oct 2023 22:23:03 +
Subject: [PATCH 1/4] Update stdckdint.h and make it available in pre-C23
 modes.

Update some tests and docs.
---
 clang/docs/ReleaseNotes.rst| 2 +-
 clang/lib/Headers/stdckdint.h  | 4 
 clang/test/C/C2x/n2359.c   | 5 -
 clang/test/C/C2x/n2683.c   | 1 +
 clang/test/C/C2x/n2683_2.c | 1 +
 clang/test/Headers/stdckdint.c | 7 +--
 6 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fc8caf9221b9d29..d0de52a5bf122f4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -177,7 +177,7 @@ C23 Feature Support
 - Clang now supports ``N3007 Type inference for object definitions``.
 
 - Clang now supports  which defines several macros for 
performing
-  checked integer arithmetic.
+  checked integer arithmetic. And it is also exposed in pre-C23 modes.
 
 Non-comprehensive list of changes in this release
 -
diff --git a/clang/lib/Headers/stdckdint.h b/clang/lib/Headers/stdckdint.h
index 22972d78d9077a4..77290b260ff3bd4 100644
--- a/clang/lib/Headers/stdckdint.h
+++ b/clang/lib/Headers/stdckdint.h
@@ -21,9 +21,6 @@
 
 /* C23 7.20.1 Defines several macros for performing checked integer 
arithmetic*/
 
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
-#define __STDC_VERSION_STDCKDINT_H__ 202311L
-
 // Both A and B shall be any integer type other than "plain" char, bool, a bit-
 // precise integer type, or an enumerated type, and they need not be the same.
 
@@ -38,7 +35,6 @@
 #define ckd_add(R, A, B) __builtin_add_overflow((A), (B), (R))
 #define ckd_sub(R, A, B) __builtin_sub_overflow((A), (B), (R))
 #define ckd_mul(R, A, B) __builtin_mul_overflow((A), (B), (R))
-#endif
 
 #endif /* __STDC_HOSTED__ */
 #endif /* __STDCKDINT_H */
diff --git a/clang/test/C/C2x/n2359.c b/clang/test/C/C2x/n2359.c
index dc38bab43c9db8d..0a1b801e505e146 100644
--- a/clang/test/C/C2x/n2359.c
+++ b/clang/test/C/C2x/n2359.c
@@ -33,8 +33,3 @@
 #error "__STDC_VERSION_STDINT_H__ not defined"
 // expected-error@-1 {{"__STDC_VERSION_STDINT_H__ not defined"}}
 #endif
-
-#include 
-#ifndef __STDC_VERSION_STDCKDINT_H__
-#error "__STDC_VERSION_STDCKDINT_H__ not defined"
-#endif
diff --git a/clang/test/C/C2x/n2683.c b/clang/test/C/C2x/n2683.c
index 0c666c5fd8782ba..a785d46c063c2cc 100644
--- a/clang/test/C/C2x/n2683.c
+++ b/clang/test/C/C2x/n2683.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c2x %s
 // RUN: %clang_cc1 -triple=x86_64 -verify -ffreestanding -std=c23 %s
 
 /* WG14 N2683: Clang 18
diff --git a/clang/test/C/C2x/n2683_2.c b/clang/test/C/C2x/n2683_2.c
index 247f6de8fe4bfe1..867d6b876cf0d9d 100644
--- a/clang/test/C/C2x/n2683_2.c
+++ b/clang/test/C/C2x/n2683_2.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -o - -std=c2x %s | FileCheck %s
 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -o - -std=c23 %s | FileCheck %s
 
 #include 
diff --git a/clang/test/Headers/stdckdint.c b/clang/test/Headers/stdckdint.c
index 896c740360065b6..7774cecfa7c3317 100644
--- a/clang/test/Headers/stdckdint.c
+++ b/clang/test/Headers/stdckdint.c
@@ -1,12 +1,15 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c99 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c11 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c17 %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c2x %s -o - | 
FileCheck %s
 // RUN: %clang_cc1 -triple=x86_64 -emit-llvm -verify -std=c23 %s -o - | 
FileCheck %s
 
 // expected-no-diagnostics
 
+#include 
 #include 
 
-_Static_assert(__STDC_VERSION_STDCKDINT_H__ == 202311L, "");
-
 // CHECK-LABEL: define dso_local zeroext i1 @test_ckd_add(
 // CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:

>From 4e2fd920121b15e014a6146c6c6672973bae4443 Mon Sep 17 00:00:00 2001
From: zijunzhao 
Date: Thu, 19 Oct 2023 22:23:03 +
Subject: [PATCH 2/4] Update stdckdint.h and make it available in pre-C23
 modes.

Update some tests and docs.
---
 clang/docs/ReleaseNotes.rst   | 2 +-
 clang/lib/Headers/stdckdint.h | 4 
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d0de52a5bf122f4..1b1f25ae244ef9f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -177,7 +177,7 @@ C23 Feature Support
 - Clang 

[Lldb-commits] [lldb] [LLDB] Update docs on building documentation (PR #69858)

2023-10-23 Thread Aiden Grossman via lldb-commits

https://github.com/boomanaiden154 updated 
https://github.com/llvm/llvm-project/pull/69858

>From 4d94c5fae6f72e3ad551cf3381b0a0e9efecbf9a Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Sat, 21 Oct 2023 15:46:39 -0700
Subject: [PATCH 1/2] [LLDB] Update docs on building documentation

This patch updates the documentation to match recent changes and make it more
clear. More specifically, the process for installing sphinx has changed with
the transition to myst with the requirements.txt in llvm/docs being the
preferred method for installation now. In addition, the docs-lldb-html target
is never generated if swig isn't installed, so having something expliti in
the documentation section (even if it is mentioned as a dependency of lldb
itself above) probably doesn't hurt.
---
 lldb/docs/resources/build.rst | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index b405a20e239912c..ae3a8ce4a25 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -403,13 +403,21 @@ dependencies are required:
 * Sphinx (for the website and the Python API reference)
 * Graphviz (for the 'dot' tool)
 * doxygen (if you wish to build the C++ API reference)
+* Swig (for generating Python bindings)
 
-To install the prerequisites for building the documentation (on Debian/Ubuntu)
+To install the system prerequisites for building the documentation (on 
Debian/Ubuntu)
 do:
 
 ::
 
-  $ sudo apt-get install doxygen graphviz python3-sphinx
+  $ sudo apt-get install doxygen graphviz swig
+
+To install Sphinx and its dependencies, use the ``requirements.txt`` available 
within LLVM
+to ensure you get a working configuration:
+
+::
+
+  $ pip3 install -r /path/to/llvm-project/llvm/docs/requirements.txt
 
 To build the documentation, configure with ``LLVM_ENABLE_SPHINX=ON`` and build 
the desired target(s).
 

>From 751343cb0442247485c0e8fa151aa94535001e69 Mon Sep 17 00:00:00 2001
From: Aiden Grossman 
Date: Mon, 23 Oct 2023 12:55:06 -0700
Subject: [PATCH 2/2] Replace Swig with SWIG to address reviewer feedback

---
 lldb/docs/resources/build.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index ae3a8ce4a25..0ccfef32a601e18 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -403,7 +403,7 @@ dependencies are required:
 * Sphinx (for the website and the Python API reference)
 * Graphviz (for the 'dot' tool)
 * doxygen (if you wish to build the C++ API reference)
-* Swig (for generating Python bindings)
+* SWIG (for generating Python bindings)
 
 To install the system prerequisites for building the documentation (on 
Debian/Ubuntu)
 do:

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


[Lldb-commits] [lldb] 2f15082 - [LLDB] Update docs on building documentation (#69858)

2023-10-23 Thread via lldb-commits

Author: Aiden Grossman
Date: 2023-10-23T12:59:39-07:00
New Revision: 2f15082b15f12461246e9e1fe1ea0cb106c27a34

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

LOG: [LLDB] Update docs on building documentation (#69858)

This patch updates the documentation to match recent changes and make it
more clear. More specifically, the process for installing sphinx has
changed with the transition to myst with the requirements.txt in
llvm/docs being the preferred method for installation now. In addition,
the docs-lldb-html target is never generated if swig isn't installed, so
having something expliti in the documentation section (even if it is
mentioned as a dependency of lldb itself above) probably doesn't hurt.

Added: 


Modified: 
lldb/docs/resources/build.rst

Removed: 




diff  --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index b405a20e239912c..0ccfef32a601e18 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -403,13 +403,21 @@ dependencies are required:
 * Sphinx (for the website and the Python API reference)
 * Graphviz (for the 'dot' tool)
 * doxygen (if you wish to build the C++ API reference)
+* SWIG (for generating Python bindings)
 
-To install the prerequisites for building the documentation (on Debian/Ubuntu)
+To install the system prerequisites for building the documentation (on 
Debian/Ubuntu)
 do:
 
 ::
 
-  $ sudo apt-get install doxygen graphviz python3-sphinx
+  $ sudo apt-get install doxygen graphviz swig
+
+To install Sphinx and its dependencies, use the ``requirements.txt`` available 
within LLVM
+to ensure you get a working configuration:
+
+::
+
+  $ pip3 install -r /path/to/llvm-project/llvm/docs/requirements.txt
 
 To build the documentation, configure with ``LLVM_ENABLE_SPHINX=ON`` and build 
the desired target(s).
 



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


[Lldb-commits] [lldb] [LLDB] Update docs on building documentation (PR #69858)

2023-10-23 Thread Aiden Grossman via lldb-commits

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


[Lldb-commits] [lldb] [lldb][lldb-server] Enable sending RegisterFlags as XML (PR #69951)

2023-10-23 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> And if you're not familiar with lldb-server and XML, as I wasn't, it doesn't 
> use libXML to generate it. That's why I'm building strings to fit with the 
> existing target.xml code.

It's somewhat implied, but is the goal to (continue to) avoid that dependency? 
Other parts of LLDB do rely on libxml2 but I can see how you'd want to limit 
the dependencies of `lldb-server`. 

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


[Lldb-commits] [lldb] [clang-format] Don't break between string literal operands of << (PR #69871)

2023-10-23 Thread Owen Pan via lldb-commits

owenca wrote:

> I think adding the possibility of breaking '<<' is a good idea if it's 
> optional, what do u think?

+1, but see also 
https://github.com/llvm/llvm-project/pull/69859#issuecomment-1776064714.

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


[Lldb-commits] [lldb] [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (PR #69388)

2023-10-23 Thread Jonas Devlieghere via lldb-commits

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

LGTM with the filename updated. 

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


[Lldb-commits] [lldb] [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (PR #69388)

2023-10-23 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (PR #69388)

2023-10-23 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,120 @@
+//===-- InstrumentationRuntimeASan.cpp 
===//

JDevlieghere wrote:

I know it's a bit unwieldy, but should this file be called 
`InstrumentationRuntimeASanLibsanitizers`? 

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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread Greg Clayton via lldb-commits

clayborg wrote:

> Making sure I'm following along properly. For context, this is the debug 
> experience I'm most used to: 
> ![Capture](https://user-images.githubusercontent.com/4587626/277433029-e45937dc-9b78-4a3d-9321-1fa99a35daa8.PNG)
> 
> It sounds like you're saying we shouldn't change the enum formatter to 
> display `Enum (1)`, it should continue to display just `Enum`. But the 
> summary could be changed for enumerations so it says `(1)`, so that both 
> pieces of information would appear in the debugger by default?

The summary should just display "1" (no parens). 

If we have the following code in C/C++:
```
  enum Foo {
   Bar = 1,
   Baz,
   Ding
  };
  Foo f = Bar;  
```
And we stop after the last line, we can do:
```
>>> v = lldb.frame.FindVariable('f')
>>> v.GetValue()
'Bar'
>>> v.GetFormat()
0
>>> lldb.eFormatDefault
0
>>> v.SetFormat(lldb.eFormatHex)
>>> v.GetValue()
'0x0001'
>>> v.SetFormat(lldb.eFormatDecimal)
>>> v.GetValue()
'1'
```
And if you set the summary to be the signed unsigned value then we would have 
this:
```
>>> v.GetSummary()
'1'
```
Where right now it returns `None`

If the user changes the format and we did the patch the way it was currently 
coded we would get:
```
>>> v.SetFormat(lldb.eFormatDecimal)
>>> v.GetValue()
`1(1)`
```
Since the normal value would listen to the format value (which defaults to 
`lldb.eFormatDefault` which is zero), but is now set to `lldb.eFormatDecimal`.

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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread Greg Clayton via lldb-commits

clayborg wrote:

What IDE are you using for the screenshot above? The issue you might run into 
is that IDE might only be showing the value string and not the summary string. 
XCode and Visual Studio code will show the value if there is one _and_ the 
summary if there is one. If there is no value (structs and class instances have 
no values), then they show the summary only.

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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread Greg Clayton via lldb-commits

clayborg wrote:

If we have a "Foo *", the value will show up as the pointer value _and_ the 
summary for the Pointee (if `Foo` has a summary provider, it will show a 
summary for it along with the pointer. If we have a "Foo", then there will be 
no value for the struct/class instance and it will show the summary for "Foo" 
if there is one. Summaries are often used for collection classes and might be 
something like "size = 1".

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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread Greg Clayton via lldb-commits

clayborg wrote:

Another thing other IDEs do is show something like "{...}" as the value for a 
struct/union/class. This is what Visual Studio used to do.

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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread via lldb-commits

jimingham wrote:

This is a mostly orthogonal comment, but at some point, we really should switch 
all the summaries that pretend to be the value of a variable to value providing 
Synthetic Children.

Summaries are currently playing two fairly different roles, one some free-form 
text that describes the value but has no semantic meaning and the other to 
represent some structure that acts as a scalar "value" when used, so it's 
supposed to stand in for the value.  That makes life hard for clients, since 
you have no good way to know whether you should use GetValueAsCString or 
GetSummary in the value field for a variable.

Using a synthetic child provider as first conceived was awkward for this, 
because the a synthetic child was always ValueObject child of the top level 
value, which means you have to disclose an opaque toplevel to see what is 
supposed to be the value of the data type.  

When we started doing swift, this came up a lot so we added "value providing 
synthetic child providers" where you can reply 0 to num_children, and you be 
asked get_value instead, and the SBValue that returns will act much like the 
dynamic type does, and replace the original ValueObject with the one you 
returned.  That makes a good presentation for this "formal scalar value".

Then summary strings could go back to always being "side notes" on the 
variable's value, which should make client's lives easier...

C-strings are still tricky, since to users they really always have two values, 
the memory address, and the contents of that memory address up to the next 
null...

Jim


> On Oct 23, 2023, at 3:05 PM, Greg Clayton ***@***.***> wrote:
> 
> 
> Another thing other IDEs do is show something like "{...}" as the value for a 
> struct/union/class. This is what Visual Studio used to do.
> 
> —
> Reply to this email directly, view it on GitHub 
> , or 
> unsubscribe 
> .
> You are receiving this because you are on a team that was mentioned.
> 



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


[Lldb-commits] [lldb] [lldb] Add value to enumerator dump (PR #69815)

2023-10-23 Thread Greg Clayton via lldb-commits

clayborg wrote:

I agree with what Jim said as well. I would rather see the IDEs add the ability 
to change the format for the values like Xcode can so that people can see their 
values as needed. The summary here isn't a perfect option for this because if 
you switch the format to `lldb::eFormatDecimal` we will see "1" as the value 
and "1" as the summary. 

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


[Lldb-commits] [PATCH] D159314: [lldb] Introduce OperatingSystem{, Python}Interface and make us it

2023-10-23 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 557856.
mib marked 2 inline comments as done.
mib added a comment.

Address @bulbazord comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159314/new/

https://reviews.llvm.org/D159314

Files:
  lldb/include/lldb/Interpreter/Interfaces/OperatingSystemInterface.h
  lldb/include/lldb/Interpreter/ScriptInterpreter.h
  lldb/include/lldb/lldb-forward.h
  lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
  lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.h
  lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt
  
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/OperatingSystemPythonInterface.cpp
  
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/OperatingSystemPythonInterface.h
  
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
  lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp

Index: lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
===
--- lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
+++ lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp
@@ -320,6 +320,11 @@
 }
 
 python::PythonObject
-lldb_private::python::SWIGBridge::ToSWIGWrapper(const StructuredDataImpl &) {
+lldb_private::python::SWIGBridge::ToSWIGWrapper(lldb::ProcessSP) {
+  return python::PythonObject();
+}
+
+python::PythonObject lldb_private::python::SWIGBridge::ToSWIGWrapper(
+const lldb_private::StructuredDataImpl &) {
   return python::PythonObject();
 }
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h
@@ -134,24 +134,9 @@
 
   lldb::ScriptedProcessInterfaceUP CreateScriptedProcessInterface() override;
 
-  StructuredData::GenericSP
-  OSPlugin_CreatePluginObject(const char *class_name,
-  lldb::ProcessSP process_sp) override;
-
-  StructuredData::DictionarySP
-  OSPlugin_RegisterInfo(StructuredData::ObjectSP os_plugin_object_sp) override;
   lldb::ScriptedThreadInterfaceSP CreateScriptedThreadInterface() override;
 
-  StructuredData::ArraySP
-  OSPlugin_ThreadsInfo(StructuredData::ObjectSP os_plugin_object_sp) override;
-
-  StructuredData::StringSP
-  OSPlugin_RegisterContextData(StructuredData::ObjectSP os_plugin_object_sp,
-   lldb::tid_t thread_id) override;
-
-  StructuredData::DictionarySP
-  OSPlugin_CreateThread(StructuredData::ObjectSP os_plugin_object_sp,
-lldb::tid_t tid, lldb::addr_t context) override;
+  lldb::OperatingSystemInterfaceSP CreateOperatingSystemInterface() override;
 
   StructuredData::ObjectSP
   LoadPluginModule(const FileSpec &file_spec,
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -14,6 +14,7 @@
 // LLDB Python header must be included first
 #include "lldb-python.h"
 
+#include "Interfaces/OperatingSystemPythonInterface.h"
 #include "Interfaces/ScriptedPlatformPythonInterface.h"
 #include "Interfaces/ScriptedProcessPythonInterface.h"
 #include "Interfaces/ScriptedThreadPythonInterface.h"
@@ -1521,6 +1522,11 @@
   return std::make_shared(*this);
 }
 
+OperatingSystemInterfaceSP
+ScriptInterpreterPythonImpl::CreateOperatingSystemInterface() {
+  return std::make_shared(*this);
+}
+
 StructuredData::ObjectSP
 ScriptInterpreterPythonImpl::CreateStructuredDataFromScriptObject(
 ScriptObject obj) {
@@ -1532,159 +1538,6 @@
   return py_obj.CreateStructuredObject();
 }
 
-StructuredData::GenericSP
-ScriptInterpreterPythonImpl::OSPlugin_CreatePluginObject(
-const char *class_name, lldb::ProcessSP process_sp) {
-  if (class_name == nullptr || class_name[0] == '\0')
-return StructuredData::GenericSP();
-
-  if (!process_sp)
-return StructuredData::GenericSP();
-
-  Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock);
-  PythonObject ret_val = SWIGBridge::LLDBSWIGPythonCreateOSPlugin(
-  class_name, m_dictionary_name.c_str(), process_sp);
-
-  return StructuredData::GenericSP(
-  new StructuredPythonObject(std::move(ret_val)));
-}
-
-StructuredData::DictionarySP ScriptInterpreterPythonImpl::OSPlugin_RegisterInfo(
-StructuredData::ObjectSP os_plugin_object_sp) {
-  Locker py_lock(this, Locker::AcquireLock | Locker::NoSTDIN, Locker::FreeLock);
-
-  if (!os_plugin_object_sp)
-r

[Lldb-commits] [lldb] 83a6b02 - [lldb] Move comments and add missing periods (NFC)

2023-10-23 Thread Jonas Devlieghere via lldb-commits

Author: Jonas Devlieghere
Date: 2023-10-23T15:29:01-07:00
New Revision: 83a6b02c3d79f0ac714690e1baec14efb1c24fe9

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

LOG: [lldb] Move comments and add missing periods (NFC)

Move comments to the line before the member variables and add missing
periods.

Added: 


Modified: 
lldb/include/lldb/Utility/FileSpec.h

Removed: 




diff  --git a/lldb/include/lldb/Utility/FileSpec.h 
b/lldb/include/lldb/Utility/FileSpec.h
index 6eb5b805d9d9f79..f06a8543a056e87 100644
--- a/lldb/include/lldb/Utility/FileSpec.h
+++ b/lldb/include/lldb/Utility/FileSpec.h
@@ -437,12 +437,20 @@ class FileSpec {
 No
   };
 
-  // Member variables
-  ConstString m_directory;///< The uniqued directory path
-  ConstString m_filename; ///< The uniqued filename path
-  mutable bool m_is_resolved = false; ///< True if this path has been resolved.
-  mutable Absolute m_absolute = Absolute::Calculate; ///< Cache absoluteness.
-  Style m_style; ///< The syntax that this path uses (e.g. Windows / Posix)
+  /// The unique'd directory path.
+  ConstString m_directory;
+
+  /// The unique'd filename path.
+  ConstString m_filename;
+
+  /// True if this path has been resolved.
+  mutable bool m_is_resolved = false;
+
+  /// Cache whether this path is absolute.
+  mutable Absolute m_absolute = Absolute::Calculate;
+
+  /// The syntax that this path uses. (e.g. Windows / Posix)
+  Style m_style;
 };
 
 /// Dump a FileSpec object to a stream



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


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-23 Thread Jason Molenda via lldb-commits


@@ -0,0 +1,140 @@
+//===-- WatchpointResource.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+
+#include "lldb/Breakpoint/WatchpointCollection.h"
+#include "lldb/lldb-public.h"
+
+#include 
+
+namespace lldb_private {
+
+class WatchpointResource
+: public std::enable_shared_from_this {
+
+public:
+  // Constructors and Destructors
+  WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write);
+
+  ~WatchpointResource();
+
+  void GetMemoryRange(lldb::addr_t &addr, size_t &size) const;
+
+  lldb::addr_t GetAddress() const;
+
+  size_t GetByteSize() const;
+
+  void GetType(bool &read, bool &write) const;
+
+  void SetType(bool read, bool write);
+
+  /// The "Owners" are the watchpoints that share this resource.
+  /// The method adds the \a owner to this resource's owner list.
+  ///
+  /// \param[in] owner
+  ///\a owner is the Wachpoint to add.
+  void AddOwner(const lldb::WatchpointSP &owner);
+
+  /// The method removes the owner at \a owner from this watchpoint
+  /// resource.
+  void RemoveOwner(lldb::WatchpointSP &owner);
+
+  /// This method returns the number of Watchpoints currently using
+  /// watchpoint resource.
+  ///
+  /// \return
+  ///The number of owners.
+  size_t GetNumberOfOwners();
+
+  /// This method returns the Watchpoint at index \a index using this
+  /// Resource.  The owners are listed ordinally from 0 to
+  /// GetNumberOfOwners() - 1 so you can use this method to iterate over the
+  /// owners.
+  ///
+  /// \param[in] idx
+  /// The index in the list of owners for which you wish the owner 
location.
+  ///
+  /// \return
+  ///The Watchpoint at that index.
+  lldb::WatchpointSP GetOwnerAtIndex(size_t idx);
+
+  /// Check if the owners includes a watchpoint.
+  ///
+  /// \param[in] wp_sp
+  /// The WatchpointSP to search for.
+  ///
+  /// \result
+  /// true if this resource's owners includes the watchpoint.
+  bool OwnersContains(lldb::WatchpointSP &wp_sp);
+
+  /// Check if the owners includes a watchpoint.
+  ///
+  /// \param[in] wp
+  /// The Watchpoint to search for.
+  ///
+  /// \result
+  /// true if this resource's owners includes the watchpoint.
+  bool OwnersContains(const lldb_private::Watchpoint *wp);
+
+  /// This method copies the watchpoint resource's owners into a new 
collection.
+  /// It does this while the owners mutex is locked.
+  ///
+  /// \param[out] out_collection
+  ///The BreakpointLocationCollection into which to put the owners
+  ///of this breakpoint site.
+  ///
+  /// \return
+  ///The number of elements copied into out_collection.
+  size_t CopyOwnersList(WatchpointCollection &out_collection);
+
+  // The ID of the WatchpointResource is set by the WatchpointResourceList
+  // when the Resource has been set in the inferior and is being added
+  // to the List, in an attempt to match the hardware watchpoint register
+  // ordering.  If a Process can correctly identify the hardware watchpoint
+  // register index when it has created the Resource, it may initialize it
+  // before it is inserted in the WatchpointResourceList.
+  void SetID(lldb::wp_resource_id_t);

jasonmolenda wrote:

When the Process method is given a watchpoint request from the user, which must 
be broken into one or more WatchpointResources (or an existing 
WatchpointResource reused), we can only get the hardware register number by 
looking at the IDs of currently allocated WatchpointResources in the 
WatchpointResourceList, which start at 0.  I assume that the remote stub will 
allocate its watchpoints in the hardware registers starting at index 0, and 
when removing/disabling them, will leave that slot unused until another request 
comes along, at which point the stub will start from 0 and look for the first 
unused hardware register.

In the specific case of gdb remote serial protocol (ProcessGDBRemote), it has 
none of this.  The Z2/Z3/Z4 packets don't tell you what hardware register was 
used.  

Today, lldb sets the hardware watchpoint index based on the watchpoint access 
stop.  SOME ways of passing the watchpoint trap back to lldb can communicate 
the hardware watchpoint index.  The standard gdb remote serial protocol does 
not with its `watch/rwatch/awatch:address` key-value in the stop packet.  
lldb-server has a different way of reporting watchpoints, `reason:watchpoint` 
and `description:addr[ index]` where the address is sent in the description: 
and it may be followed by a space and then the index number of the hardware 
watchpoint that was triggered.  For macOS systems,

[Lldb-commits] [lldb] [lldb] Refactor InstrumentationRuntimeAsan and add a new plugin (PR #69388)

2023-10-23 Thread Alex Langford via lldb-commits

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

Thanks for breaking it up, that made it easier for me to review.
I don't see any issues with it right now, so LGTM.

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


[Lldb-commits] [lldb] [lldb] [mostly NFC] Large WP foundation: WatchpointResources (PR #68845)

2023-10-23 Thread Jason Molenda via lldb-commits


@@ -0,0 +1,140 @@
+//===-- WatchpointResource.h *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+#define LLDB_BREAKPOINT_WATCHPOINTRESOURCE_H
+
+#include "lldb/Breakpoint/WatchpointCollection.h"
+#include "lldb/lldb-public.h"
+
+#include 
+
+namespace lldb_private {
+
+class WatchpointResource
+: public std::enable_shared_from_this {
+
+public:
+  // Constructors and Destructors
+  WatchpointResource(lldb::addr_t addr, size_t size, bool read, bool write);
+
+  ~WatchpointResource();
+
+  void GetMemoryRange(lldb::addr_t &addr, size_t &size) const;
+
+  lldb::addr_t GetAddress() const;
+
+  size_t GetByteSize() const;
+
+  void GetType(bool &read, bool &write) const;
+
+  void SetType(bool read, bool write);
+
+  /// The "Owners" are the watchpoints that share this resource.
+  /// The method adds the \a owner to this resource's owner list.
+  ///
+  /// \param[in] owner
+  ///\a owner is the Wachpoint to add.
+  void AddOwner(const lldb::WatchpointSP &owner);
+
+  /// The method removes the owner at \a owner from this watchpoint
+  /// resource.
+  void RemoveOwner(lldb::WatchpointSP &owner);
+
+  /// This method returns the number of Watchpoints currently using
+  /// watchpoint resource.
+  ///
+  /// \return
+  ///The number of owners.
+  size_t GetNumberOfOwners();
+
+  /// This method returns the Watchpoint at index \a index using this
+  /// Resource.  The owners are listed ordinally from 0 to
+  /// GetNumberOfOwners() - 1 so you can use this method to iterate over the
+  /// owners.
+  ///
+  /// \param[in] idx
+  /// The index in the list of owners for which you wish the owner 
location.
+  ///
+  /// \return
+  ///The Watchpoint at that index.
+  lldb::WatchpointSP GetOwnerAtIndex(size_t idx);
+
+  /// Check if the owners includes a watchpoint.
+  ///
+  /// \param[in] wp_sp
+  /// The WatchpointSP to search for.
+  ///
+  /// \result
+  /// true if this resource's owners includes the watchpoint.
+  bool OwnersContains(lldb::WatchpointSP &wp_sp);
+
+  /// Check if the owners includes a watchpoint.
+  ///
+  /// \param[in] wp
+  /// The Watchpoint to search for.
+  ///
+  /// \result
+  /// true if this resource's owners includes the watchpoint.
+  bool OwnersContains(const lldb_private::Watchpoint *wp);
+
+  /// This method copies the watchpoint resource's owners into a new 
collection.
+  /// It does this while the owners mutex is locked.
+  ///
+  /// \param[out] out_collection
+  ///The BreakpointLocationCollection into which to put the owners
+  ///of this breakpoint site.
+  ///
+  /// \return
+  ///The number of elements copied into out_collection.
+  size_t CopyOwnersList(WatchpointCollection &out_collection);
+
+  // The ID of the WatchpointResource is set by the WatchpointResourceList
+  // when the Resource has been set in the inferior and is being added
+  // to the List, in an attempt to match the hardware watchpoint register
+  // ordering.  If a Process can correctly identify the hardware watchpoint
+  // register index when it has created the Resource, it may initialize it
+  // before it is inserted in the WatchpointResourceList.
+  void SetID(lldb::wp_resource_id_t);

jasonmolenda wrote:

To be honest, I'm VERY close to just removing the hardware index numbers 
altogether and having SBWatchpoint::GetHardwareIndex return UINT32_MAX.  It 
might be the better idea than these convoluted things I'm doing to try to 
heuristically guess the hw index.

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


[Lldb-commits] [lldb] [lldb] Add `SBModule.SetLocateDwoCallback` (PR #69517)

2023-10-23 Thread Alex Langford via lldb-commits

bulbazord wrote:

In that case, maybe it doesn't make sense for every Debugger to have its own 
callback and SymbolFile should own it? Can't say I'm a fan of having this 
effectively be a global variable since I've seen it be an issue in other 
situations (e.g. Logging).

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


[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-23 Thread Adrian Prantl via lldb-commits

https://github.com/adrian-prantl created 
https://github.com/llvm/llvm-project/pull/69981

I need this API in the Swift plugin, but it seems generally useful enough to 
expose it in the main branch.

>From 6b41e8ccaf7c3daf787cb7f7399ba815c5fe5b77 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Mon, 23 Oct 2023 15:55:40 -0700
Subject: [PATCH] Expose DWARFDIE::GetDeclContext() in lldb_private::Function.

I need this API in the Swift plugin, but it seems generally useful
enough to expose it in the main branch.
---
 lldb/include/lldb/Symbol/Function.h   |  6 
 lldb/include/lldb/Symbol/SymbolFile.h | 12 ---
 lldb/include/lldb/Symbol/Type.h   |  2 +-
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  |  9 +++---
 .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp | 32 ++-
 .../Plugins/SymbolFile/DWARF/DWARFDIE.h   |  2 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  | 14 ++--
 .../SymbolFile/DWARF/SymbolFileDWARF.h|  3 ++
 .../DWARF/SymbolFileDWARFDebugMap.cpp | 13 ++--
 .../DWARF/SymbolFileDWARFDebugMap.h   |  2 ++
 lldb/source/Symbol/Function.cpp   | 23 -
 lldb/source/Symbol/Type.cpp   | 32 ++-
 .../DWARF/x86/find-basic-function.cpp |  2 +-
 .../SymbolFile/DWARF/x86/module-ownership.mm  |  2 +-
 lldb/tools/lldb-test/lldb-test.cpp| 12 ---
 15 files changed, 113 insertions(+), 53 deletions(-)

diff --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 28afdbff1eb233e..de69fd949d24748 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -533,6 +533,12 @@ class Function : public UserID, public SymbolContextScope {
   /// The DeclContext, or NULL if none exists.
   CompilerDeclContext GetDeclContext();
 
+  /// Get the CompilerContext for this function, if available.
+  ///
+  /// \return
+  /// The CompilerContext, or NULL if none exists.
+  std::vector GetCompilerContext();
+
   /// Get accessor for the type that describes the function return value type,
   /// and parameter types.
   ///
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index 512dd9acb86db61..b40d0f03b6e0130 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -225,14 +225,16 @@ class SymbolFile : public PluginInterface {
 
   virtual bool CompleteType(CompilerType &compiler_type) = 0;
   virtual void ParseDeclsForContext(CompilerDeclContext decl_ctx) {}
-  virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid) {
-return CompilerDecl();
-  }
+  virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid) { return {}; }
   virtual CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid) {
-return CompilerDeclContext();
+return {};
   }
   virtual CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) 
{
-return CompilerDeclContext();
+return {};
+  }
+  virtual std::vector
+  GetCompilerContextForUID(lldb::user_id_t uid) {
+return {};
   }
   virtual uint32_t ResolveSymbolContext(const Address &so_addr,
 lldb::SymbolContextItem resolve_scope,
diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index c505262cd9eaecf..3d9ed2183d81ecd 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -34,7 +34,7 @@ struct CompilerContext {
   }
   bool operator!=(const CompilerContext &rhs) const { return !(*this == rhs); }
 
-  void Dump() const;
+  void Dump(Stream *s) const;
 
   CompilerContextKind kind;
   ConstString name;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 545a5dcc7d0fd09..43d61a9f66c0ba2 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -142,8 +142,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const 
SymbolContext &sc,
   // If this type comes from a Clang module, recursively look in the
   // DWARF section of the .pcm file in the module cache. Clang
   // generates DWO skeleton units as breadcrumbs to find them.
-  llvm::SmallVector decl_context;
-  die.GetDeclContext(decl_context);
+  std::vector decl_context = die.GetDeclContext();
   TypeMap pcm_types;
 
   // The type in the Clang module must have the same language as the current 
CU.
@@ -2286,7 +2285,7 @@ CompilerDecl 
DWARFASTParserClang::GetDeclForUIDFromDWARF(const DWARFDIE &die) {
   clang::Decl *clang_decl = GetClangDeclForDIE(die);
   if (clang_decl != nullptr)
 return m_ast.GetCompilerDecl(clang_decl);
-  return CompilerDecl();
+  return {};
 }
 
 CompilerDeclContext
@@ -2294,7 +2293,7 @@ DWARFASTParserClang::GetDeclContextForUIDFromDWARF(const 
DWARFDIE &die) {
   clang::DeclContext *clang_decl_ctx = GetClangD

[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Adrian Prantl (adrian-prantl)


Changes

I need this API in the Swift plugin, but it seems generally useful enough to 
expose it in the main branch.

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


15 Files Affected:

- (modified) lldb/include/lldb/Symbol/Function.h (+6) 
- (modified) lldb/include/lldb/Symbol/SymbolFile.h (+7-5) 
- (modified) lldb/include/lldb/Symbol/Type.h (+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
(+4-5) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp (+17-15) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h (+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (+12-2) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (+3) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
(+11-2) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h 
(+2) 
- (modified) lldb/source/Symbol/Function.cpp (+22-1) 
- (modified) lldb/source/Symbol/Type.cpp (+17-15) 
- (modified) lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-function.cpp 
(+1-1) 
- (modified) lldb/test/Shell/SymbolFile/DWARF/x86/module-ownership.mm (+1-1) 
- (modified) lldb/tools/lldb-test/lldb-test.cpp (+8-4) 


``diff
diff --git a/lldb/include/lldb/Symbol/Function.h 
b/lldb/include/lldb/Symbol/Function.h
index 28afdbff1eb233e..de69fd949d24748 100644
--- a/lldb/include/lldb/Symbol/Function.h
+++ b/lldb/include/lldb/Symbol/Function.h
@@ -533,6 +533,12 @@ class Function : public UserID, public SymbolContextScope {
   /// The DeclContext, or NULL if none exists.
   CompilerDeclContext GetDeclContext();
 
+  /// Get the CompilerContext for this function, if available.
+  ///
+  /// \return
+  /// The CompilerContext, or NULL if none exists.
+  std::vector GetCompilerContext();
+
   /// Get accessor for the type that describes the function return value type,
   /// and parameter types.
   ///
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h 
b/lldb/include/lldb/Symbol/SymbolFile.h
index 512dd9acb86db61..b40d0f03b6e0130 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -225,14 +225,16 @@ class SymbolFile : public PluginInterface {
 
   virtual bool CompleteType(CompilerType &compiler_type) = 0;
   virtual void ParseDeclsForContext(CompilerDeclContext decl_ctx) {}
-  virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid) {
-return CompilerDecl();
-  }
+  virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid) { return {}; }
   virtual CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid) {
-return CompilerDeclContext();
+return {};
   }
   virtual CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) 
{
-return CompilerDeclContext();
+return {};
+  }
+  virtual std::vector
+  GetCompilerContextForUID(lldb::user_id_t uid) {
+return {};
   }
   virtual uint32_t ResolveSymbolContext(const Address &so_addr,
 lldb::SymbolContextItem resolve_scope,
diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index c505262cd9eaecf..3d9ed2183d81ecd 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -34,7 +34,7 @@ struct CompilerContext {
   }
   bool operator!=(const CompilerContext &rhs) const { return !(*this == rhs); }
 
-  void Dump() const;
+  void Dump(Stream *s) const;
 
   CompilerContextKind kind;
   ConstString name;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 545a5dcc7d0fd09..43d61a9f66c0ba2 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -142,8 +142,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const 
SymbolContext &sc,
   // If this type comes from a Clang module, recursively look in the
   // DWARF section of the .pcm file in the module cache. Clang
   // generates DWO skeleton units as breadcrumbs to find them.
-  llvm::SmallVector decl_context;
-  die.GetDeclContext(decl_context);
+  std::vector decl_context = die.GetDeclContext();
   TypeMap pcm_types;
 
   // The type in the Clang module must have the same language as the current 
CU.
@@ -2286,7 +2285,7 @@ CompilerDecl 
DWARFASTParserClang::GetDeclForUIDFromDWARF(const DWARFDIE &die) {
   clang::Decl *clang_decl = GetClangDeclForDIE(die);
   if (clang_decl != nullptr)
 return m_ast.GetCompilerDecl(clang_decl);
-  return CompilerDecl();
+  return {};
 }
 
 CompilerDeclContext
@@ -2294,7 +2293,7 @@ DWARFASTParserClang::GetDeclContextForUIDFromDWARF(const 
DWARFDIE &die) {
   clang::DeclContext *clang_decl_ctx = GetClangDeclContextForDIE(die);
   if (clang_decl_ctx)
 return m_ast.CreateDeclContext(clang_decl_ctx);
-  return CompilerDeclCont

[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-23 Thread Walter Erquinigo via lldb-commits

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


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


[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-23 Thread Jonas Devlieghere via lldb-commits


@@ -533,6 +533,12 @@ class Function : public UserID, public SymbolContextScope {
   /// The DeclContext, or NULL if none exists.
   CompilerDeclContext GetDeclContext();
 
+  /// Get the CompilerContext for this function, if available.
+  ///
+  /// \return
+  /// The CompilerContext, or NULL if none exists.
+  std::vector GetCompilerContext();

JDevlieghere wrote:

This comment is wrong/out of date.

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


[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-23 Thread Alex Langford via lldb-commits

https://github.com/bulbazord commented:

overall LGTM, few questions though

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


[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-23 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-23 Thread Alex Langford via lldb-commits


@@ -816,6 +818,8 @@ Expected 
opts::symbols::getAction() {
   "Specify search type (-find) to use search options.");
 return dumpModule;
 
+
+

bulbazord wrote:

Spurious whitespace

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


[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-23 Thread Alex Langford via lldb-commits


@@ -519,7 +530,17 @@ CompilerDeclContext Function::GetDeclContext() {
 if (SymbolFile *sym_file = module_sp->GetSymbolFile())
   return sym_file->GetDeclContextForUID(GetID());
   }
-  return CompilerDeclContext();
+  return {};
+}
+
+std::vector Function::GetCompilerContext() {
+  ModuleSP module_sp = CalculateSymbolContextModule();
+
+  if (module_sp) {

bulbazord wrote:

You can roll these into 1 line as well.

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


[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-23 Thread Alex Langford via lldb-commits


@@ -1391,7 +1391,16 @@ 
SymbolFileDWARFDebugMap::GetDeclContextContainingUID(lldb::user_id_t type_uid) {
   SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
   if (oso_dwarf)
 return oso_dwarf->GetDeclContextContainingUID(type_uid);
-  return CompilerDeclContext();
+  return {};
+}
+
+std::vector
+SymbolFileDWARFDebugMap::GetCompilerContextForUID(lldb::user_id_t type_uid) {
+  const uint64_t oso_idx = GetOSOIndexFromUserID(type_uid);
+  SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx);
+  if (oso_dwarf)

bulbazord wrote:

You can roll these lines into 1
```
if (SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx))
```

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


[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-23 Thread Alex Langford via lldb-commits


@@ -142,8 +142,7 @@ TypeSP DWARFASTParserClang::ParseTypeFromClangModule(const 
SymbolContext &sc,
   // If this type comes from a Clang module, recursively look in the
   // DWARF section of the .pcm file in the module cache. Clang
   // generates DWO skeleton units as breadcrumbs to find them.
-  llvm::SmallVector decl_context;
-  die.GetDeclContext(decl_context);
+  std::vector decl_context = die.GetDeclContext();

bulbazord wrote:

Why the change from `llvm::SmallVector<$Type, 4>` to `std::vector`? Does this 
not generally contain 4 or fewer CompilerContexts anymore?

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


[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-23 Thread Alex Langford via lldb-commits


@@ -533,6 +533,12 @@ class Function : public UserID, public SymbolContextScope {
   /// The DeclContext, or NULL if none exists.
   CompilerDeclContext GetDeclContext();
 
+  /// Get the CompilerContext for this function, if available.
+  ///
+  /// \return
+  /// The CompilerContext, or NULL if none exists.
+  std::vector GetCompilerContext();

bulbazord wrote:

The docs and the declaration conflict.

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


[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-23 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 840d0b7e03045c30b052dce8d0bb82f3fa0c5d6d 
6b41e8ccaf7c3daf787cb7f7399ba815c5fe5b77 -- lldb/include/lldb/Symbol/Function.h 
lldb/include/lldb/Symbol/SymbolFile.h lldb/include/lldb/Symbol/Type.h 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h 
lldb/source/Symbol/Function.cpp lldb/source/Symbol/Type.cpp 
lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-function.cpp 
lldb/tools/lldb-test/lldb-test.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index b5bfa31a40a8..1f9524f8add9 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -407,7 +407,7 @@ std::vector 
DWARFDIE::GetDeclContext() const {
 push_ctx(CompilerContextKind::Function, GetPubname());
 break;
   case DW_TAG_variable:
-push_ctx(CompilerContextKind::Variable, GetPubname());
+push_ctx(CompilerContextKind::Variable, GetPubname());
 break;
   case DW_TAG_typedef:
 push_ctx(CompilerContextKind::Typedef, GetName());
diff --git a/lldb/tools/lldb-test/lldb-test.cpp 
b/lldb/tools/lldb-test/lldb-test.cpp
index fa758bae5023..cfdbc18b6c5a 100644
--- a/lldb/tools/lldb-test/lldb-test.cpp
+++ b/lldb/tools/lldb-test/lldb-test.cpp
@@ -818,8 +818,6 @@ Expected 
opts::symbols::getAction() {
   "Specify search type (-find) to use search options.");
 return dumpModule;
 
-
-
   case FindType::Function:
 if (!File.empty() + (Line != 0) == 1)
   return make_string_error("Both file name and line number must be "

``




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


[Lldb-commits] [lldb] 61c4ee9 - [lldb][NFC] Implement llvm-style RTTI for DWARFASTParser (#69762)

2023-10-23 Thread via lldb-commits

Author: Augusto Noronha
Date: 2023-10-23T16:25:18-07:00
New Revision: 61c4ee94498f99f45b630bc491ad11db236a3b82

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

LOG: [lldb][NFC] Implement llvm-style RTTI for DWARFASTParser (#69762)

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
index eaafbe169cc8cfc..99527fb83f1fa0a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -29,6 +29,9 @@ class SymbolFileDWARF;
 
 class DWARFASTParser {
 public:
+  enum class Kind { DWARFASTParserClang, DWARFASTParserSwift };
+  DWARFASTParser(Kind kind) : m_kind(kind) {}
+
   virtual ~DWARFASTParser() = default;
 
   virtual lldb::TypeSP ParseTypeFromDWARF(const SymbolContext &sc,
@@ -62,6 +65,11 @@ class DWARFASTParser {
   const ExecutionContext *exe_ctx = nullptr);
 
   static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility);
+
+  Kind GetKind() const { return m_kind; }
+
+private:
+  const Kind m_kind;
 };
 } // namespace dwarf
 } // namespace lldb_private::plugin

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 545a5dcc7d0fd09..5d107ce63b8bc25 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -63,7 +63,8 @@ using namespace lldb_private::dwarf;
 using namespace lldb_private::plugin::dwarf;
 
 DWARFASTParserClang::DWARFASTParserClang(TypeSystemClang &ast)
-: m_ast(ast), m_die_to_decl_ctx(), m_decl_ctx_to_die() {}
+: DWARFASTParser(Kind::DWARFASTParserClang), m_ast(ast),
+  m_die_to_decl_ctx(), m_decl_ctx_to_die() {}
 
 DWARFASTParserClang::~DWARFASTParserClang() = default;
 

diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index 3d6912cf56c1779..d58fcf4a64dab3b 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -248,6 +248,10 @@ class DWARFASTParserClang : public 
lldb_private::plugin::dwarf::DWARFASTParser {
   lldb::ModuleSP
   GetModuleForType(const lldb_private::plugin::dwarf::DWARFDIE &die);
 
+  static bool classof(const DWARFASTParser *Parser) {
+return Parser->GetKind() == Kind::DWARFASTParserClang;
+  }
+
 private:
   struct FieldInfo {
 uint64_t bit_size = 0;



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


[Lldb-commits] [lldb] [lldb][NFC] Implement llvm-style RTTI for DWARFASTParser (PR #69762)

2023-10-23 Thread Augusto Noronha via lldb-commits

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


[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-23 Thread Michael Buch via lldb-commits


@@ -396,6 +396,17 @@ void Function::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
 s->AsRawOstream() << ", name = \"" << name << '"';
   if (mangled)
 s->AsRawOstream() << ", mangled = \"" << mangled << '"';
+  if (level == eDescriptionLevelVerbose) {
+*s << ", decl_context = {";
+auto decl_context = GetCompilerContext();
+// Drop the function itself from the context chain.
+if (decl_context.size())
+  decl_context.pop_back();
+llvm::interleave(

Michael137 wrote:

can't you use `interleaveComma` here?

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


[Lldb-commits] [lldb] [lldb][NFC] Move GetTypeForDIE from to DWARFASTParser (PR #69764)

2023-10-23 Thread Augusto Noronha via lldb-commits

https://github.com/augusto2112 updated 
https://github.com/llvm/llvm-project/pull/69764

>From d84b4b293a97b75a34e4208c914988a2e5231d66 Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Fri, 20 Oct 2023 12:59:00 -0700
Subject: [PATCH] [lldb][NFC] Move GetTypeForDIE from to DWARFASTParser

---
 .../SymbolFile/DWARF/DWARFASTParser.cpp   | 25 +++
 .../Plugins/SymbolFile/DWARF/DWARFASTParser.h |  3 +++
 .../SymbolFile/DWARF/DWARFASTParserClang.cpp  | 24 --
 .../SymbolFile/DWARF/DWARFASTParserClang.h|  3 ---
 4 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp
index 1fe0cadecc9e70e..409e9bb37ab28b9 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp
@@ -9,6 +9,7 @@
 #include "DWARFASTParser.h"
 #include "DWARFAttribute.h"
 #include "DWARFDIE.h"
+#include "SymbolFileDWARF.h"
 
 #include "lldb/Core/ValueObject.h"
 #include "lldb/Symbol/SymbolFile.h"
@@ -100,6 +101,30 @@ DWARFASTParser::ParseChildArrayInfo(const DWARFDIE 
&parent_die,
   return array_info;
 }
 
+Type *DWARFASTParser::GetTypeForDIE(const DWARFDIE &die) {
+  if (!die)
+return nullptr;
+
+  SymbolFileDWARF *dwarf = die.GetDWARF();
+  if (!dwarf)
+return nullptr;
+
+  DWARFAttributes attributes = die.GetAttributes();
+  if (attributes.Size() == 0)
+return nullptr;
+
+  DWARFFormValue type_die_form;
+  for (size_t i = 0; i < attributes.Size(); ++i) {
+dw_attr_t attr = attributes.AttributeAtIndex(i);
+DWARFFormValue form_value;
+
+if (attr == DW_AT_type && attributes.ExtractFormValueAtIndex(i, 
form_value))
+  return dwarf->ResolveTypeUID(form_value.Reference(), true);
+  }
+
+  return nullptr;
+}
+
 AccessType
 DWARFASTParser::GetAccessTypeFromDWARF(uint32_t dwarf_accessibility) {
   switch (dwarf_accessibility) {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
index eaafbe169cc8cfc..19dcee508d59377 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -61,6 +61,9 @@ class DWARFASTParser {
   ParseChildArrayInfo(const DWARFDIE &parent_die,
   const ExecutionContext *exe_ctx = nullptr);
 
+  lldb_private::Type *
+  GetTypeForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);
+
   static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility);
 };
 } // namespace dwarf
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 545a5dcc7d0fd09..72670b9a83f001c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3292,30 +3292,6 @@ size_t DWARFASTParserClang::ParseChildParameters(
   return arg_idx;
 }
 
-Type *DWARFASTParserClang::GetTypeForDIE(const DWARFDIE &die) {
-  if (!die)
-return nullptr;
-
-  SymbolFileDWARF *dwarf = die.GetDWARF();
-  if (!dwarf)
-return nullptr;
-
-  DWARFAttributes attributes = die.GetAttributes();
-  if (attributes.Size() == 0)
-return nullptr;
-
-  DWARFFormValue type_die_form;
-  for (size_t i = 0; i < attributes.Size(); ++i) {
-dw_attr_t attr = attributes.AttributeAtIndex(i);
-DWARFFormValue form_value;
-
-if (attr == DW_AT_type && attributes.ExtractFormValueAtIndex(i, 
form_value))
-  return dwarf->ResolveTypeUID(form_value.Reference(), true);
-  }
-
-  return nullptr;
-}
-
 clang::Decl *DWARFASTParserClang::GetClangDeclForDIE(const DWARFDIE &die) {
   if (!die)
 return nullptr;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
index 3d6912cf56c1779..f70868b793e7098 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h
@@ -199,9 +199,6 @@ class DWARFASTParserClang : public 
lldb_private::plugin::dwarf::DWARFASTParser {
 const lldb_private::plugin::dwarf::DWARFDIE &die,
 ParsedDWARFTypeAttributes &attrs);
 
-  lldb_private::Type *
-  GetTypeForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);
-
   clang::Decl *
   GetClangDeclForDIE(const lldb_private::plugin::dwarf::DWARFDIE &die);
 

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


[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-23 Thread Michael Buch via lldb-commits


@@ -322,10 +322,12 @@ std::vector parseCompilerContext() {
 }
 result.push_back({kind, ConstString{value}});
   }
-  outs() << "Search context: {\n";
-  for (auto entry: result)
-entry.Dump();
-  outs() << "}\n";
+  outs() << "Search context: {";
+  lldb_private::StreamString s;
+  llvm::interleave(

Michael137 wrote:

`interleaveComma`

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


[Lldb-commits] [lldb] Expose DWARFDIE::GetDeclContext() in lldb_private::Function. (PR #69981)

2023-10-23 Thread Michael Buch via lldb-commits


@@ -396,6 +396,17 @@ void Function::GetDescription(Stream *s, 
lldb::DescriptionLevel level,
 s->AsRawOstream() << ", name = \"" << name << '"';
   if (mangled)
 s->AsRawOstream() << ", mangled = \"" << mangled << '"';
+  if (level == eDescriptionLevelVerbose) {
+*s << ", decl_context = {";
+auto decl_context = GetCompilerContext();
+// Drop the function itself from the context chain.
+if (decl_context.size())
+  decl_context.pop_back();
+llvm::interleave(

Michael137 wrote:

Oh unless it doesn't work with this particular stream...

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


[Lldb-commits] [lldb] [lldb][NFC] Remote reference to Swift in DWARFASTParser::Kind enum (PR #69984)

2023-10-23 Thread Augusto Noronha via lldb-commits

https://github.com/augusto2112 created 
https://github.com/llvm/llvm-project/pull/69984

None

>From 2500e7fadc72c56a887b27d5f271bea5af70ccab Mon Sep 17 00:00:00 2001
From: Augusto Noronha 
Date: Mon, 23 Oct 2023 16:35:24 -0700
Subject: [PATCH] [lldb][NFC] Remote reference to Swift in DWARFASTParser::Kind
 enum

---
 lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
index 99527fb83f1fa0a..1efe0ff347d9c8f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h
@@ -29,7 +29,7 @@ class SymbolFileDWARF;
 
 class DWARFASTParser {
 public:
-  enum class Kind { DWARFASTParserClang, DWARFASTParserSwift };
+  enum class Kind { DWARFASTParserClang };
   DWARFASTParser(Kind kind) : m_kind(kind) {}
 
   virtual ~DWARFASTParser() = default;

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


  1   2   >