[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [pstl] Update IDE Folders (PR #89153)

2024-04-23 Thread James Henderson via lldb-commits

jh7370 wrote:

> This looks like a nice improvement for folks using those generators. Even 
> though most of these changes look straightforward, it would be a lot easier 
> to review if this was broken up per subproject. Is there any reason that's 
> not possible?

+1 to this: 195 files is too many to review in a single PR really, so if we 
have an alternative, incremental approach, we should take that. (Also big +1 to 
the improvement though).

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


[Lldb-commits] [lldb] [lldb] fix python extension debug suffix on Win (PR #89037)

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


@@ -75,6 +75,12 @@ if (LLDB_ENABLE_PYTHON)
   endif()
 endif()
   endforeach()
+  if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL Debug)
+string(SUBSTRING ${LLDB_PYTHON_EXT_SUFFIX} 0 2 FIRST_2_CHARS)
+if(NOT FIRST_2_CHARS STREQUAL "_d")

DavidSpickett wrote:

Add some comments to explain why we have this check, something like:
```
# If we are using a debug Python, the expected suffix will already have "_d".
if (...)
  # We are using a release Python, but the lldb extension will be built with 
the "_d" suffix.
```

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


[Lldb-commits] [lldb] [lldb] Enable support for Markdown documentation pages (PR #89716)

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

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

RST is powerful but usually too powerful for 90% of what we need it for. 
Markdown is easier to edit and can be previewed easily without building the 
entire website.

This copies what llvm does already, making myst_parser optional if you only 
want man pages.

Previously we had Markdown enabled in 8b95bd3310c126e76e0714bea6003a9b1aa739fb 
but that got reverted. That did this in a different way, I've gone with the 
standard llvm set this time.

I intend the first Markdown pages to be the remote protocol extension docs, as 
they are not in any set format right now.

>From 9067fdfa42b0ba59119d910b49cf3147d57310dc Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Mon, 22 Apr 2024 09:04:42 +0100
Subject: [PATCH] [lldb] Enable support for Markdown documentation pages

RST is powerful but usually too powerful for 90% of what we need
it for. Markdown is easier to edit and can be previewed easily
without building the entire website.

This copies what llvm does already, making myst_parser optional
if you only want man pages.

Previously we had Markdown enabled in 8b95bd3310c126e76e0714bea6003a9b1aa739fb
but that got reverted. That did this in a different way,
I've gone with the standard llvm set this time.

I intend the first Markdown pages to be the remote protocol
extension docs, as they are not in any set format right now.
---
 lldb/docs/conf.py | 21 +
 1 file changed, 21 insertions(+)

diff --git a/lldb/docs/conf.py b/lldb/docs/conf.py
index ec7f93710ab6f2..27a1cd7c3c31ac 100644
--- a/lldb/docs/conf.py
+++ b/lldb/docs/conf.py
@@ -13,6 +13,9 @@
 import sys, os, re, shutil
 from datetime import date
 
+# Add path for llvm_slug module.
+sys.path.insert(0, os.path.abspath(os.path.join("..", "..", "llvm", "docs")))
+
 building_man_page = tags.has("builder-man")
 
 # For the website we need to setup the path to the generated LLDB module that
@@ -42,6 +45,23 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ["sphinx.ext.todo", "sphinx.ext.mathjax", 
"sphinx.ext.intersphinx"]
 
+# When building man pages, we do not use the markdown pages,
+# So, we can continue without the myst_parser dependencies.
+# Doing so reduces dependencies of some packaged llvm distributions.
+try:
+import myst_parser
+
+extensions.append("myst_parser")
+except ImportError:
+if not tags.has("builder-man"):
+raise
+
+# Automatic anchors for markdown titles
+from llvm_slug import make_slug
+
+myst_heading_anchors = 6
+myst_heading_slug_func = make_slug
+
 autodoc_default_options = {"special-members": True}
 
 # Unless we only generate the basic manpage we need the plugin for generating
@@ -69,6 +89,7 @@
 # The suffix of source filenames.
 source_suffix = {
 ".rst": "restructuredtext",
+".md": "markdown",
 }
 
 # The encoding of source files.

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


[Lldb-commits] [lldb] [lldb] Enable support for Markdown documentation pages (PR #89716)

2024-04-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

RST is powerful but usually too powerful for 90% of what we need it for. 
Markdown is easier to edit and can be previewed easily without building the 
entire website.

This copies what llvm does already, making myst_parser optional if you only 
want man pages.

Previously we had Markdown enabled in 8b95bd3310c126e76e0714bea6003a9b1aa739fb 
but that got reverted. That did this in a different way, I've gone with the 
standard llvm set this time.

I intend the first Markdown pages to be the remote protocol extension docs, as 
they are not in any set format right now.

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


1 Files Affected:

- (modified) lldb/docs/conf.py (+21) 


``diff
diff --git a/lldb/docs/conf.py b/lldb/docs/conf.py
index ec7f93710ab6f2..27a1cd7c3c31ac 100644
--- a/lldb/docs/conf.py
+++ b/lldb/docs/conf.py
@@ -13,6 +13,9 @@
 import sys, os, re, shutil
 from datetime import date
 
+# Add path for llvm_slug module.
+sys.path.insert(0, os.path.abspath(os.path.join("..", "..", "llvm", "docs")))
+
 building_man_page = tags.has("builder-man")
 
 # For the website we need to setup the path to the generated LLDB module that
@@ -42,6 +45,23 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ["sphinx.ext.todo", "sphinx.ext.mathjax", 
"sphinx.ext.intersphinx"]
 
+# When building man pages, we do not use the markdown pages,
+# So, we can continue without the myst_parser dependencies.
+# Doing so reduces dependencies of some packaged llvm distributions.
+try:
+import myst_parser
+
+extensions.append("myst_parser")
+except ImportError:
+if not tags.has("builder-man"):
+raise
+
+# Automatic anchors for markdown titles
+from llvm_slug import make_slug
+
+myst_heading_anchors = 6
+myst_heading_slug_func = make_slug
+
 autodoc_default_options = {"special-members": True}
 
 # Unless we only generate the basic manpage we need the plugin for generating
@@ -69,6 +89,7 @@
 # The suffix of source filenames.
 source_suffix = {
 ".rst": "restructuredtext",
+".md": "markdown",
 }
 
 # The encoding of source files.

``




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


[Lldb-commits] [lldb] [lldb][Docs] Convert GDB protocol extensions doc to Markdown and add to website (PR #89718)

2024-04-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)


Changes

This document has never been on the website, unlike GDB's protocol docs. It 
will be useful to have both available online to compare.

Markdown is easier to edit and preview in many editors (including Github 
itself), so I've chosen that over RST. Plus, building the website takes minutes 
and I lose the will to make nice edits when I have to deal with that.

The standard dialiect lacks some things notably multi-line table cells, so I've 
converted large tables into bullet point lists
so that we still get text wrapping. This is a downside but I think the 
simplicity of Markdown outweighs this.

I have applied the plain text markers where I've noticed it and escaped some 
HTML characters. There may be more changes needed but, it's Markdown, so it's 
in theory a lot easier for someone to fix it!

---

Patch is 199.01 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/89718.diff


3 Files Affected:

- (modified) lldb/docs/index.rst (+1) 
- (removed) lldb/docs/lldb-gdb-remote.txt (-2286) 
- (added) lldb/docs/resources/lldbgdbremote.md (+2399) 


``diff
diff --git a/lldb/docs/index.rst b/lldb/docs/index.rst
index c378ab97d97bbb..6906566ea55e58 100644
--- a/lldb/docs/index.rst
+++ b/lldb/docs/index.rst
@@ -157,6 +157,7 @@ interesting areas to contribute to lldb.
resources/sbapi
resources/dataformatters
resources/extensions
+   resources/lldbgdbremote
resources/caveats
resources/projects
Public C++ API 
diff --git a/lldb/docs/lldb-gdb-remote.txt b/lldb/docs/lldb-gdb-remote.txt
deleted file mode 100644
index 6c29de61daba7e..00
--- a/lldb/docs/lldb-gdb-remote.txt
+++ /dev/null
@@ -1,2286 +0,0 @@
-LLDB has added new GDB server packets to better support multi-threaded and
-remote debugging. Why? Normally you need to start the correct GDB and the
-correct GDB server when debugging. If you have mismatch, then things go wrong
-very quickly. LLDB makes extensive use of the GDB remote protocol and we
-wanted to make sure that the experience was a bit more dynamic where we can
-discover information about a remote target without having to know anything up
-front. We also ran into performance issues with the existing GDB remote
-protocol that can be overcome when using a reliable communications layer.
-Some packets improve performance, others allow for remote process launching
-(if you have an OS), and others allow us to dynamically figure out what
-registers a thread might have. Again with GDB, both sides pre-agree on how the
-registers will look (how many, their register number,name and offsets). We
-prefer to be able to dynamically determine what kind of architecture, OS and
-vendor we are debugging, as well as how things are laid out when it comes to
-the thread register contexts. Below are the details on the new packets we have
-added above and beyond the standard GDB remote protocol packets.
-
-//--
-// "QStartNoAckMode"
-//
-// BRIEF
-//  Try to enable no ACK mode to skip sending ACKs and NACKs.
-//
-// PRIORITY TO IMPLEMENT
-//  High. Any GDB remote server that can implement this should if the
-//  connection is reliable. This improves packet throughput and increases
-//  the performance of the connection.
-//--
-Having to send an ACK/NACK after every packet slows things down a bit, so we
-have a way to disable ACK packets to minimize the traffic for reliable
-communication interfaces (like sockets). Below GDB or LLDB will send this
-packet to try and disable ACKs. All lines that start with "send packet: " are
-from GDB/LLDB, and all lines that start with "read packet: " are from the GDB
-remote server:
-
-send packet: $QStartNoAckMode#b0
-read packet: +
-read packet: $OK#9a
-send packet: +
-
-//--
-// "QSupported"
-//
-// BRIEF
-//  Query the GDB remote server for features it supports
-//
-// PRIORITY TO IMPLEMENT
-//  Optional.
-//--
-
-QSupported is a standard GDB Remote Serial Protocol packet, but
-there are several additions to the response that lldb can parse.
-They are not all listed here.
-
-An example exchange:
-
-send packet: 
qSupported:xmlRegisters=i386,arm,mips,arc;multiprocess+;fork-events+;vfork-events+
-
-read packet: 
qXfer:features:read+;PacketSize=2;qEcho+;native-signals+;SupportedCompressions=lzfse,zlib-deflate,lz4,lzma;SupportedWatchpointTypes=aarch64-mask,aarch64-bas;
-
-In the example above, three lldb extensions are shown:
-
-  PacketSize=2
-The base 16 maximum packet size that the stub can handle.
-  SupportedCompressions=
-A list of compression types that the stub can use to c

[Lldb-commits] [lldb] [lldb][Docs] Make formatting regular in lldb-gdb-remote.txt (PR #89587)

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

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


[Lldb-commits] [lldb] [lldb][Docs] Make formatting regular in lldb-gdb-remote.txt (PR #89587)

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

DavidSpickett wrote:

I'll include this as a commit in a larger PR.

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


[Lldb-commits] [lldb] [lldb][Docs] Convert GDB protocol extensions doc to Markdown and add to website (PR #89718)

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

DavidSpickett wrote:

As it stands this PR *will not* build, because it requires 
https://github.com/llvm/llvm-project/pull/89716. I wanted to put up both to 
show what I'm going to do with all this.

First https://github.com/llvm/llvm-project/pull/89716 should land, so we can 
flush out any builds that don't have the packages installed. Then this PR would 
go in.

This PR is multiple commits but since comments on 
https://github.com/llvm/llvm-project/pull/89587 wanted to avoid churn, they'll 
be squashed into one. I just want to make sure it's as reviewable as it can be, 
even if each one is a giant change.

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


[Lldb-commits] [lldb] [lldb] Enable support for Markdown documentation pages (PR #89716)

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

DavidSpickett wrote:

This will be used by https://github.com/llvm/llvm-project/pull/89718, but I 
would like to land this PR first to flush out any bot config problems.

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


[Lldb-commits] [lldb] [lldb][Docs] Make formatting regular in lldb-gdb-remote.txt (PR #89587)

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

DavidSpickett wrote:

Opened https://github.com/llvm/llvm-project/pull/89718 instead, which has all 
the conversion steps in it.

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


[Lldb-commits] [lldb] [lldb] Enable support for Markdown documentation pages (PR #89716)

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

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


[Lldb-commits] [lldb] dbcfb43 - [lldb/test] Rename a function

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

Author: Pavel Labath
Date: 2024-04-23T09:11:58Z
New Revision: dbcfb434a9c7fea194c7b1f7f04f0947f88dbc85

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

LOG: [lldb/test] Rename a function

I misunderstood what is the function looking up

Added: 


Modified: 
lldb/test/API/python_api/type/TestTypeList.py

Removed: 




diff  --git a/lldb/test/API/python_api/type/TestTypeList.py 
b/lldb/test/API/python_api/type/TestTypeList.py
index 09c1dee80ef6c4..c647c2bcdccb6f 100644
--- a/lldb/test/API/python_api/type/TestTypeList.py
+++ b/lldb/test/API/python_api/type/TestTypeList.py
@@ -18,7 +18,7 @@ def setUp(self):
 self.source = "main.cpp"
 self.line = line_number(self.source, "// Break at this line")
 
-def _find_nested_type_in_Task_pointer(self, pointer_type):
+def _find_nested_type_in_Pointer_template_arg(self, pointer_type):
 self.assertTrue(pointer_type)
 self.DebugSBType(pointer_type)
 pointer_info_type = pointer_type.template_args[1]
@@ -168,8 +168,10 @@ def test(self):
 
 # Check that FindDirectNestedType works with types from module and
 # expression ASTs.
-
self._find_nested_type_in_Task_pointer(frame0.FindVariable("pointer").GetType())
-self._find_nested_type_in_Task_pointer(
+self._find_nested_type_in_Pointer_template_arg(
+frame0.FindVariable("pointer").GetType()
+)
+self._find_nested_type_in_Pointer_template_arg(
 frame0.EvaluateExpression("pointer").GetType()
 )
 



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


[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)

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

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

The main change is the addition of a new SBTypeStaticField class, representing 
a static member of a class. It can be retrieved created through 
SBType::GetStaticFieldWithName. It contains several methods (GetName, 
GetMangledName, etc.) whose meaning is hopefully obvious. The most interesting 
method is
lldb::SBValue GetConstantValue(lldb::SBTarget)
which returns a the value of the field -- if it is a compile time constant. The 
reason for that is that only constants have their values represented in the 
clang AST.

For non-constants, we need to go back to the module containing that constant, 
and ask retrieve the associated ValueObjectVariable. That's easy enough if the 
we are still in the type system of the module (because then the type system 
will contain the pointer to the module symbol file), but it's hard when the 
type has been copied into another AST (e.g. during expression evaluation). To 
do that we would need to walk the ast import chain backwards to find the source 
TypeSystem, and I haven't found a nice way to do that.

Another possibility would be to use the mangled name of the variable to perform 
a lookup (in all modules). That is sort of what happens when evaluating the 
variable in an expression (which does work), but I did not want to commit to 
that implementation as it's not necessary for my use case (and if anyone wants 
to, he can use the GetMangledName function and perform the lookup manually).

The patch adds a couple of new TypeSystem functions to surface the information 
needed to implement this functionality.

>From 091db4a89de2678fbdcc2db3051f34eeb8cc0cf2 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 23 Apr 2024 08:50:31 +
Subject: [PATCH] [lldb] Add SB API to access static constexpr member values

The main change is the addition of a new SBTypeStaticField class,
representing a static member of a class. It can be retrieved created
through SBType::GetStaticFieldWithName it contains several methods
(GetName, GetMangledName, etc.) whose meaning is hopefully obvious. The
most interesting method is
lldb::SBValue GetConstantValue(lldb::SBTarget)
which returns a the value of the field -- if it is a compile time
constant. The reason for that is that only constants have their values
represented in the clang AST.

For non-constants, we need to go back to the module containing that
constant, and ask retrive the associated ValueObjectVariable. That's
easy enough if the we are still in the type system of the module
(because then the type system will contain the pointer to the module
symbol file), but it's hard when the type has been copied into another
AST (e.g. during expression evaluation). To do that we would need to
walk the ast import chain backwards to find the source TypeSystem, and I
haven't found a nice way to do that.

Another possibility would be to use the mangled name of the variable to
perform a lookup (in all modules). That is sort of what happens when
evaluating the variable in an expression (which does work), but I did
not want to commit to that implementation as it's not necessary for my
use case (and if anyone wants to, he can use the GetMangledName function
and perform the lookup manually).

The patch adds a couple of new TypeSystem functions to surface the
information needed to implement this functionality.
---
 lldb/include/lldb/API/SBTarget.h  |  1 +
 lldb/include/lldb/API/SBType.h| 32 +++
 lldb/include/lldb/API/SBValue.h   |  1 +
 lldb/include/lldb/Symbol/CompilerDecl.h   |  7 ++
 lldb/include/lldb/Symbol/CompilerType.h   |  2 +
 lldb/include/lldb/Symbol/TypeSystem.h |  9 ++
 lldb/source/API/SBType.cpp| 88 +++
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 52 +++
 .../TypeSystem/Clang/TypeSystemClang.h|  8 ++
 lldb/source/Symbol/CompilerDecl.cpp   |  9 ++
 lldb/source/Symbol/CompilerType.cpp   |  6 ++
 lldb/test/API/python_api/type/TestTypeList.py | 26 ++
 lldb/test/API/python_api/type/main.cpp|  1 +
 13 files changed, 242 insertions(+)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 3644ac056da3dc..823615e6a36df5 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -954,6 +954,7 @@ class LLDB_API SBTarget {
   friend class SBSection;
   friend class SBSourceManager;
   friend class SBSymbol;
+  friend class SBTypeStaticField;
   friend class SBValue;
   friend class SBVariablesOptions;
 
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 9980fe1218305b..7767eace0cebfe 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -107,6 +107,35 @@ class SBTypeMemberFunction {
   lldb::TypeMemberFunctionImplSP m_opaque_sp;
 };
 
+class LLDB_API SBTypeStaticField {
+public:
+  SBTypeStat

[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)

2024-04-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

The main change is the addition of a new SBTypeStaticField class, representing 
a static member of a class. It can be retrieved created through 
SBType::GetStaticFieldWithName. It contains several methods (GetName, 
GetMangledName, etc.) whose meaning is hopefully obvious. The most interesting 
method is
lldb::SBValue GetConstantValue(lldb::SBTarget)
which returns a the value of the field -- if it is a compile time constant. The 
reason for that is that only constants have their values represented in the 
clang AST.

For non-constants, we need to go back to the module containing that constant, 
and ask retrieve the associated ValueObjectVariable. That's easy enough if the 
we are still in the type system of the module (because then the type system 
will contain the pointer to the module symbol file), but it's hard when the 
type has been copied into another AST (e.g. during expression evaluation). To 
do that we would need to walk the ast import chain backwards to find the source 
TypeSystem, and I haven't found a nice way to do that.

Another possibility would be to use the mangled name of the variable to perform 
a lookup (in all modules). That is sort of what happens when evaluating the 
variable in an expression (which does work), but I did not want to commit to 
that implementation as it's not necessary for my use case (and if anyone wants 
to, he can use the GetMangledName function and perform the lookup manually).

The patch adds a couple of new TypeSystem functions to surface the information 
needed to implement this functionality.

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


13 Files Affected:

- (modified) lldb/include/lldb/API/SBTarget.h (+1) 
- (modified) lldb/include/lldb/API/SBType.h (+32) 
- (modified) lldb/include/lldb/API/SBValue.h (+1) 
- (modified) lldb/include/lldb/Symbol/CompilerDecl.h (+7) 
- (modified) lldb/include/lldb/Symbol/CompilerType.h (+2) 
- (modified) lldb/include/lldb/Symbol/TypeSystem.h (+9) 
- (modified) lldb/source/API/SBType.cpp (+88) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+52) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h (+8) 
- (modified) lldb/source/Symbol/CompilerDecl.cpp (+9) 
- (modified) lldb/source/Symbol/CompilerType.cpp (+6) 
- (modified) lldb/test/API/python_api/type/TestTypeList.py (+26) 
- (modified) lldb/test/API/python_api/type/main.cpp (+1) 


``diff
diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 3644ac056da3dc..823615e6a36df5 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -954,6 +954,7 @@ class LLDB_API SBTarget {
   friend class SBSection;
   friend class SBSourceManager;
   friend class SBSymbol;
+  friend class SBTypeStaticField;
   friend class SBValue;
   friend class SBVariablesOptions;
 
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 9980fe1218305b..7767eace0cebfe 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -107,6 +107,35 @@ class SBTypeMemberFunction {
   lldb::TypeMemberFunctionImplSP m_opaque_sp;
 };
 
+class LLDB_API SBTypeStaticField {
+public:
+  SBTypeStaticField();
+
+  SBTypeStaticField(const lldb::SBTypeStaticField &rhs);
+  lldb::SBTypeStaticField &operator=(const lldb::SBTypeStaticField &rhs);
+
+  ~SBTypeStaticField();
+
+  explicit operator bool() const;
+
+  bool IsValid() const;
+
+  const char *GetName();
+
+  const char *GetMangledName();
+
+  lldb::SBType GetType();
+
+  lldb::SBValue GetConstantValue(lldb::SBTarget target);
+
+protected:
+  friend class SBType;
+
+  SBTypeStaticField(lldb_private::CompilerDecl decl);
+
+  std::unique_ptr m_opaque_up;
+};
+
 class SBType {
 public:
   SBType();
@@ -182,6 +211,8 @@ class SBType {
 
   lldb::SBTypeMember GetVirtualBaseClassAtIndex(uint32_t idx);
 
+  lldb::SBTypeStaticField GetStaticFieldWithName(const char *name);
+
   lldb::SBTypeEnumMemberList GetEnumMembers();
 
   uint32_t GetNumberOfTemplateArguments();
@@ -242,6 +273,7 @@ class SBType {
   friend class SBTypeNameSpecifier;
   friend class SBTypeMember;
   friend class SBTypeMemberFunction;
+  friend class SBTypeStaticField;
   friend class SBTypeList;
   friend class SBValue;
   friend class SBWatchpoint;
diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h
index bbcccaab51aaee..67f55ce7da2877 100644
--- a/lldb/include/lldb/API/SBValue.h
+++ b/lldb/include/lldb/API/SBValue.h
@@ -426,6 +426,7 @@ class LLDB_API SBValue {
   friend class SBModule;
   friend class SBTarget;
   friend class SBThread;
+  friend class SBTypeStaticField;
   friend class SBTypeSummary;
   friend class SBValueList;
 
diff --git a/lldb/include/lldb/Symbol/CompilerDecl.h 
b/lldb/include/lldb/Symbol/CompilerDecl.h
index 825a4f15836fce..5c99cae3781c58 100644
--- a/lldb/include/lldb/Symbol/C

[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)

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

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


[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)

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

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

LGTM with some minor clarification questions/style comments

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


[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)

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


@@ -9074,6 +9111,21 @@ CompilerType 
TypeSystemClang::DeclGetFunctionArgumentType(void *opaque_decl,
   return CompilerType();
 }
 
+Scalar TypeSystemClang::DeclGetConstantValue(void *opaque_decl) {
+  clang::Decl *decl = static_cast(opaque_decl);
+  if (clang::VarDecl *var_decl = llvm::dyn_cast(decl)) {

Michael137 wrote:

Minor: could follow the early-return style here

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


[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)

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


@@ -1156,6 +1159,10 @@ CompilerType 
TypeSystemClang::GetTypeForDecl(ObjCInterfaceDecl *decl) {
   return GetType(getASTContext().getObjCInterfaceType(decl));
 }
 
+CompilerType TypeSystemClang::GetTypeForDecl(clang::ValueDecl *value_decl) {

Michael137 wrote:

Could you remind me where the need for `ValueDecl` comes from?

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


[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)

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


@@ -27,6 +27,7 @@ class Task {
 enum E : unsigned char {} e;
 union U {
 } u;
+static constexpr long static_constexpr_field = 47;

Michael137 wrote:

Should we have an XFAIL test for the non-constant case?

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


[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)

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


@@ -107,6 +107,35 @@ class SBTypeMemberFunction {
   lldb::TypeMemberFunctionImplSP m_opaque_sp;
 };
 
+class LLDB_API SBTypeStaticField {
+public:
+  SBTypeStaticField();
+
+  SBTypeStaticField(const lldb::SBTypeStaticField &rhs);
+  lldb::SBTypeStaticField &operator=(const lldb::SBTypeStaticField &rhs);
+
+  ~SBTypeStaticField();
+
+  explicit operator bool() const;
+
+  bool IsValid() const;
+
+  const char *GetName();
+
+  const char *GetMangledName();
+
+  lldb::SBType GetType();
+
+  lldb::SBValue GetConstantValue(lldb::SBTarget target);
+
+protected:
+  friend class SBType;
+
+  SBTypeStaticField(lldb_private::CompilerDecl decl);

Michael137 wrote:

did you mean for this to not be marked `explicit`?

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


[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)

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


@@ -107,6 +107,35 @@ class SBTypeMemberFunction {
   lldb::TypeMemberFunctionImplSP m_opaque_sp;
 };
 
+class LLDB_API SBTypeStaticField {
+public:
+  SBTypeStaticField();
+
+  SBTypeStaticField(const lldb::SBTypeStaticField &rhs);
+  lldb::SBTypeStaticField &operator=(const lldb::SBTypeStaticField &rhs);
+
+  ~SBTypeStaticField();
+
+  explicit operator bool() const;
+
+  bool IsValid() const;
+
+  const char *GetName();
+
+  const char *GetMangledName();
+
+  lldb::SBType GetType();
+
+  lldb::SBValue GetConstantValue(lldb::SBTarget target);
+
+protected:
+  friend class SBType;
+
+  SBTypeStaticField(lldb_private::CompilerDecl decl);

labath wrote:

No, I did not. One could say it was implicitly implicit. :P

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


[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)

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


@@ -27,6 +27,7 @@ class Task {
 enum E : unsigned char {} e;
 union U {
 } u;
+static constexpr long static_constexpr_field = 47;

labath wrote:

Good idea.

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


[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)

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


@@ -1156,6 +1159,10 @@ CompilerType 
TypeSystemClang::GetTypeForDecl(ObjCInterfaceDecl *decl) {
   return GetType(getASTContext().getObjCInterfaceType(decl));
 }
 
+CompilerType TypeSystemClang::GetTypeForDecl(clang::ValueDecl *value_decl) {

labath wrote:

ValueDecl is a base of VarDecl. For this patch I only need to know the types of 
`VarDecl`s, but I figured I could use the lowest class that does the trick 
(defines `getType`), in case that's useful in the future.

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


[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)

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


@@ -1156,6 +1159,10 @@ CompilerType 
TypeSystemClang::GetTypeForDecl(ObjCInterfaceDecl *decl) {
   return GetType(getASTContext().getObjCInterfaceType(decl));
 }
 
+CompilerType TypeSystemClang::GetTypeForDecl(clang::ValueDecl *value_decl) {

Michael137 wrote:

Ahh makes sense, didn't look at the inheritance hierarchy carefully enough

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


[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)

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

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

>From 091db4a89de2678fbdcc2db3051f34eeb8cc0cf2 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Tue, 23 Apr 2024 08:50:31 +
Subject: [PATCH 1/2] [lldb] Add SB API to access static constexpr member
 values

The main change is the addition of a new SBTypeStaticField class,
representing a static member of a class. It can be retrieved created
through SBType::GetStaticFieldWithName it contains several methods
(GetName, GetMangledName, etc.) whose meaning is hopefully obvious. The
most interesting method is
lldb::SBValue GetConstantValue(lldb::SBTarget)
which returns a the value of the field -- if it is a compile time
constant. The reason for that is that only constants have their values
represented in the clang AST.

For non-constants, we need to go back to the module containing that
constant, and ask retrive the associated ValueObjectVariable. That's
easy enough if the we are still in the type system of the module
(because then the type system will contain the pointer to the module
symbol file), but it's hard when the type has been copied into another
AST (e.g. during expression evaluation). To do that we would need to
walk the ast import chain backwards to find the source TypeSystem, and I
haven't found a nice way to do that.

Another possibility would be to use the mangled name of the variable to
perform a lookup (in all modules). That is sort of what happens when
evaluating the variable in an expression (which does work), but I did
not want to commit to that implementation as it's not necessary for my
use case (and if anyone wants to, he can use the GetMangledName function
and perform the lookup manually).

The patch adds a couple of new TypeSystem functions to surface the
information needed to implement this functionality.
---
 lldb/include/lldb/API/SBTarget.h  |  1 +
 lldb/include/lldb/API/SBType.h| 32 +++
 lldb/include/lldb/API/SBValue.h   |  1 +
 lldb/include/lldb/Symbol/CompilerDecl.h   |  7 ++
 lldb/include/lldb/Symbol/CompilerType.h   |  2 +
 lldb/include/lldb/Symbol/TypeSystem.h |  9 ++
 lldb/source/API/SBType.cpp| 88 +++
 .../TypeSystem/Clang/TypeSystemClang.cpp  | 52 +++
 .../TypeSystem/Clang/TypeSystemClang.h|  8 ++
 lldb/source/Symbol/CompilerDecl.cpp   |  9 ++
 lldb/source/Symbol/CompilerType.cpp   |  6 ++
 lldb/test/API/python_api/type/TestTypeList.py | 26 ++
 lldb/test/API/python_api/type/main.cpp|  1 +
 13 files changed, 242 insertions(+)

diff --git a/lldb/include/lldb/API/SBTarget.h b/lldb/include/lldb/API/SBTarget.h
index 3644ac056da3dc..823615e6a36df5 100644
--- a/lldb/include/lldb/API/SBTarget.h
+++ b/lldb/include/lldb/API/SBTarget.h
@@ -954,6 +954,7 @@ class LLDB_API SBTarget {
   friend class SBSection;
   friend class SBSourceManager;
   friend class SBSymbol;
+  friend class SBTypeStaticField;
   friend class SBValue;
   friend class SBVariablesOptions;
 
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 9980fe1218305b..7767eace0cebfe 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -107,6 +107,35 @@ class SBTypeMemberFunction {
   lldb::TypeMemberFunctionImplSP m_opaque_sp;
 };
 
+class LLDB_API SBTypeStaticField {
+public:
+  SBTypeStaticField();
+
+  SBTypeStaticField(const lldb::SBTypeStaticField &rhs);
+  lldb::SBTypeStaticField &operator=(const lldb::SBTypeStaticField &rhs);
+
+  ~SBTypeStaticField();
+
+  explicit operator bool() const;
+
+  bool IsValid() const;
+
+  const char *GetName();
+
+  const char *GetMangledName();
+
+  lldb::SBType GetType();
+
+  lldb::SBValue GetConstantValue(lldb::SBTarget target);
+
+protected:
+  friend class SBType;
+
+  SBTypeStaticField(lldb_private::CompilerDecl decl);
+
+  std::unique_ptr m_opaque_up;
+};
+
 class SBType {
 public:
   SBType();
@@ -182,6 +211,8 @@ class SBType {
 
   lldb::SBTypeMember GetVirtualBaseClassAtIndex(uint32_t idx);
 
+  lldb::SBTypeStaticField GetStaticFieldWithName(const char *name);
+
   lldb::SBTypeEnumMemberList GetEnumMembers();
 
   uint32_t GetNumberOfTemplateArguments();
@@ -242,6 +273,7 @@ class SBType {
   friend class SBTypeNameSpecifier;
   friend class SBTypeMember;
   friend class SBTypeMemberFunction;
+  friend class SBTypeStaticField;
   friend class SBTypeList;
   friend class SBValue;
   friend class SBWatchpoint;
diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h
index bbcccaab51aaee..67f55ce7da2877 100644
--- a/lldb/include/lldb/API/SBValue.h
+++ b/lldb/include/lldb/API/SBValue.h
@@ -426,6 +426,7 @@ class LLDB_API SBValue {
   friend class SBModule;
   friend class SBTarget;
   friend class SBThread;
+  friend class SBTypeStaticField;
   friend class SBTypeSummary;
   friend class SBValueList;
 
diff --git a/lldb/include/lldb/Symbol/CompilerDecl.h 
b/lldb/in

[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [pstl] Update IDE Folders (PR #89153)

2024-04-23 Thread Michael Kruse via lldb-commits

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


[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libclc] [libcxx] [libcxxabi] [libunwind] [lld] [lldb] [llvm] [mlir] [openmp] [polly] [pstl] Update IDE Folders (PR #89153)

2024-04-23 Thread Michael Kruse via lldb-commits

Meinersbur wrote:

As suggested, I split the patch into per-subproject patches:

[LLVM](https://github.com/llvm/llvm-project/pull/89741) (dependency of the 
other patches)
[BOLT](https://github.com/llvm/llvm-project/pull/89742)
[Clang](https://github.com/llvm/llvm-project/pull/89743)
[Clang-Tools-Extra](https://github.com/llvm/llvm-project/pull/89744)
[Compiler-RT](https://github.com/llvm/llvm-project/pull/89753)
[Flang](https://github.com/llvm/llvm-project/pull/89745)
[libclc](https://github.com/llvm/llvm-project/pull/89746)
[LLD](https://github.com/llvm/llvm-project/pull/89747)
[LLDB](https://github.com/llvm/llvm-project/pull/89748)
[MLIR](https://github.com/llvm/llvm-project/pull/89749)
[OpenMP](https://github.com/llvm/llvm-project/pull/89750)
[Polly](https://github.com/llvm/llvm-project/pull/89752)
[Misc](https://github.com/llvm/llvm-project/pull/89755)

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


[Lldb-commits] [lldb] [lldb][test] Make archflags for gcc and clang -march (PR #89760)

2024-04-23 Thread via lldb-commits

https://github.com/ita-sc created 
https://github.com/llvm/llvm-project/pull/89760

Hi

It seems that by default
```
# On non-Apple platforms, -arch becomes -m
```

This patch overrides this behavior, and if it is used clang or gcc/g++, flag 
becomes `-march`



>From e9a5462ec17beca948e8a18fc7fa5edb1328c9b1 Mon Sep 17 00:00:00 2001
From: Ivan Tetyushkin 
Date: Thu, 11 Apr 2024 12:23:38 +0300
Subject: [PATCH] [lldb][test] Make archflags for gcc and clang -march

---
 .../Python/lldbsuite/test/make/Makefile.rules  | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index bfd249ccd43f2e..5206466aa12750 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -212,6 +212,20 @@ else
endif
 endif
 
+ifneq (,$(findstring gcc,$(CC)))
+   ARCHFLAG :=-march=
+endif
+ifneq (,$(findstring g++,$(CC)))
+   ARCHFLAG :=-march=
+endif
+ifneq (,$(findstring clang,$(CC)))
+   ARCHFLAG :=-march=
+endif
+ifneq (,$(findstring clang++,$(CC)))
+   ARCHFLAG :=-march=
+endif
+
+
 LIMIT_DEBUG_INFO_FLAGS =
 NO_LIMIT_DEBUG_INFO_FLAGS =
 MODULE_DEBUG_INFO_FLAGS =

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


[Lldb-commits] [lldb] [lldb][test] Make archflags for gcc and clang -march (PR #89760)

2024-04-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (ita-sc)


Changes

Hi

It seems that by default
```
# On non-Apple platforms, -arch becomes -m
```

This patch overrides this behavior, and if it is used clang or gcc/g++, flag 
becomes `-march`



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


1 Files Affected:

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


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index bfd249ccd43f2e..5206466aa12750 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -212,6 +212,20 @@ else
endif
 endif
 
+ifneq (,$(findstring gcc,$(CC)))
+   ARCHFLAG :=-march=
+endif
+ifneq (,$(findstring g++,$(CC)))
+   ARCHFLAG :=-march=
+endif
+ifneq (,$(findstring clang,$(CC)))
+   ARCHFLAG :=-march=
+endif
+ifneq (,$(findstring clang++,$(CC)))
+   ARCHFLAG :=-march=
+endif
+
+
 LIMIT_DEBUG_INFO_FLAGS =
 NO_LIMIT_DEBUG_INFO_FLAGS =
 MODULE_DEBUG_INFO_FLAGS =

``




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


[Lldb-commits] [lldb] Add ability to specify running LLDB API testsuite by json description (PR #89764)

2024-04-23 Thread via lldb-commits

https://github.com/ita-sc created 
https://github.com/llvm/llvm-project/pull/89764

Hi

This patch adds ability to set up lldb dotest.py command with json format: 
```
[
 {
"test_pack_name": "check-lldb-one", # <- mandatory
"test_pack_desc": "description for test pack", # <- mandatory
"test_compiler": "clang", # <- optional
"test_arch": "x86", # <- optional
"test_simulator": "tvos", # <- optional
"extra_flags": [ # <- optional
  "-static"
],
"skip_categories": [ # <- optional
  "lldb-vscode"
],
"xfail_categories": [ # <- optional
  "watchpoint"
],
"check_all": false # <- mandatory, if we should run it with check-all target
 },
 {...}
]
```
As result, we will run dotest with additional options 
from test_simulator: tvos: --apple-sdk appletvsimulator --platform-name 
tvos-simulator
from test_compiler: --compiler=clang
from test_arch:  --arch x86
from extra_flags: we compile our test binaries with --static.

Note: this patch also adds ability to pass several extra flags to
dotest. It is done by this syntax: start:--option1:option2.

Also we pass skip and xfail categories to dotest.py script

>From b5e6e4ab15692a5d4ec3e1bc4d04c9c98f572d08 Mon Sep 17 00:00:00 2001
From: Ivan Tetyushkin 
Date: Thu, 11 Apr 2024 11:56:12 +0300
Subject: [PATCH] Add ability to specify running LLDB API testsuite by json
 description

This patch adds ability to set up lldb dotest.py command with json format:
[
 {
"test_pack_name": "check-lldb-one", # <- mandatory
"test_pack_desc": "description for test pack", # <- mandatory
"test_compiler": "clang", # <- optional
"test_arch": "x86", # <- optional
"test_simulator": "tvos", # <- optional
"extra_flags": [ # <- optional
  "-static"
],
"skip_categories": [ # <- optional
  "lldb-vscode"
],
"xfail_categories": [ # <- optional
  "watchpoint"
],
"check_all": false # <- mandatory, if we should run it with check-all target
 },
 {...}
]

As result, we will run dotest with additional options
from test_simulator: tvos: --apple-sdk appletvsimulator --platform-name 
tvos-simulator
from test_compiler: --compiler=clang
from test_arch:  --arch x86
from extra_flags: we compile our test binaries with --static.

Note: this patch also adds ability to pass several extra flags to
dotest. It is done by this syntax: start:--option1:option2.

Also we pass skip and xfail categories to dotest.py script
---
 lldb/packages/Python/lldbsuite/test/dotest.py |  7 +-
 lldb/test/API/CMakeLists.txt  | 67 +++
 lldb/test/API/lit.cfg.py  | 28 
 3 files changed, 101 insertions(+), 1 deletion(-)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 2ec4a840b91675..1f70c6579a48a8 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -336,7 +336,12 @@ def parseOptionsAndInitTestdirs():
 )
 
 if args.E:
-os.environ["CFLAGS_EXTRAS"] = args.E
+args_list = args.E.split(":")
+# Remove first 'start' argument, as we need it was needed to pass as 
argument to '-E'
+if (args_list[0] == "start"):
+  args_list = args_list[1:]
+
+os.environ["CFLAGS_EXTRAS"] = " ".join(args_list)
 
 if args.dwarf_version:
 configuration.dwarf_version = args.dwarf_version
diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 9196f54ce1ae32..2c368daf1a7665 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -195,3 +195,70 @@ add_lit_testsuite(check-lldb-api "Running lldb api test 
suite"
   ${CMAKE_CURRENT_BINARY_DIR}
   EXCLUDE_FROM_CHECK_ALL
   DEPENDS lldb-api-test-deps)
+
+if(LLDB_API_JSON_CONFIG)
+  file(READ ${LLDB_API_JSON_CONFIG} API_TEST_CONFIGS)
+  set(IDX 0)
+  while(true)
+macro(set_test_info out_var key)
+  string(JSON ${out_var} ERROR_VARIABLE ERROR_VAR GET ${API_TEST_CONFIGS} 
${IDX} ${key})
+  if (NOT ${ERROR_VAR} MATCHES .*NOTFOUND)
+break()
+  endif()
+endmacro()
+
+set_test_info(TEST_NAME test_pack_name)
+set_test_info(TEST_DESC test_pack_desc)
+set_test_info(CHECK_ALL_NEEDED check_all)
+
+set(TO_PARAMS "" CACHE STRING "internal variable to be given to lit config 
params" FORCE)
+# function to add separate param to run lit.cfg with.
+function(add_param key substr)
+  string(JSON RES ERROR_VARIABLE ERROR_VAR GET ${API_TEST_CONFIGS} ${IDX} 
${key})
+  if (${ERROR_VAR} MATCHES .*NOTFOUND)
+ list(APPEND TO_PARAMS "${substr}=${RES}")
+  endif()
+  set(TO_PARAMS ${TO_PARAMS} PARENT_SCOPE)
+endfunction()
+# function to add a list of params to run lit.cfg with.
+function (add_list_param key substr)
+  set(LIST_IDX 0)
+  set(FULL_LINE_TO_ADD "")
+  while (true)
+string(JSON RES ERROR_VARIABLE ERROR_VAR GET ${API_TEST_CONFI

[Lldb-commits] [lldb] Add ability to specify running LLDB API testsuite by json description (PR #89764)

2024-04-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (ita-sc)


Changes

Hi

This patch adds ability to set up lldb dotest.py command with json format: 
```
[
 {
"test_pack_name": "check-lldb-one", # <- mandatory
"test_pack_desc": "description for test pack", # <- mandatory
"test_compiler": "clang", # <- optional
"test_arch": "x86", # <- optional
"test_simulator": "tvos", # <- optional
"extra_flags": [ # <- optional
  "-static"
],
"skip_categories": [ # <- optional
  "lldb-vscode"
],
"xfail_categories": [ # <- optional
  "watchpoint"
],
"check_all": false # <- mandatory, if we should run it with check-all 
target
 },
 {...}
]
```
As result, we will run dotest with additional options 
from test_simulator: tvos: --apple-sdk appletvsimulator --platform-name 
tvos-simulator
from test_compiler: --compiler=clang
from test_arch:  --arch x86
from extra_flags: we compile our test binaries with --static.

Note: this patch also adds ability to pass several extra flags to
dotest. It is done by this syntax: start:--option1:option2.

Also we pass skip and xfail categories to dotest.py script

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


3 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/dotest.py (+6-1) 
- (modified) lldb/test/API/CMakeLists.txt (+67) 
- (modified) lldb/test/API/lit.cfg.py (+28) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 2ec4a840b91675..1f70c6579a48a8 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -336,7 +336,12 @@ def parseOptionsAndInitTestdirs():
 )
 
 if args.E:
-os.environ["CFLAGS_EXTRAS"] = args.E
+args_list = args.E.split(":")
+# Remove first 'start' argument, as we need it was needed to pass as 
argument to '-E'
+if (args_list[0] == "start"):
+  args_list = args_list[1:]
+
+os.environ["CFLAGS_EXTRAS"] = " ".join(args_list)
 
 if args.dwarf_version:
 configuration.dwarf_version = args.dwarf_version
diff --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index 9196f54ce1ae32..2c368daf1a7665 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -195,3 +195,70 @@ add_lit_testsuite(check-lldb-api "Running lldb api test 
suite"
   ${CMAKE_CURRENT_BINARY_DIR}
   EXCLUDE_FROM_CHECK_ALL
   DEPENDS lldb-api-test-deps)
+
+if(LLDB_API_JSON_CONFIG)
+  file(READ ${LLDB_API_JSON_CONFIG} API_TEST_CONFIGS)
+  set(IDX 0)
+  while(true)
+macro(set_test_info out_var key)
+  string(JSON ${out_var} ERROR_VARIABLE ERROR_VAR GET ${API_TEST_CONFIGS} 
${IDX} ${key})
+  if (NOT ${ERROR_VAR} MATCHES .*NOTFOUND)
+break()
+  endif()
+endmacro()
+
+set_test_info(TEST_NAME test_pack_name)
+set_test_info(TEST_DESC test_pack_desc)
+set_test_info(CHECK_ALL_NEEDED check_all)
+
+set(TO_PARAMS "" CACHE STRING "internal variable to be given to lit config 
params" FORCE)
+# function to add separate param to run lit.cfg with.
+function(add_param key substr)
+  string(JSON RES ERROR_VARIABLE ERROR_VAR GET ${API_TEST_CONFIGS} ${IDX} 
${key})
+  if (${ERROR_VAR} MATCHES .*NOTFOUND)
+ list(APPEND TO_PARAMS "${substr}=${RES}")
+  endif()
+  set(TO_PARAMS ${TO_PARAMS} PARENT_SCOPE)
+endfunction()
+# function to add a list of params to run lit.cfg with.
+function (add_list_param key substr)
+  set(LIST_IDX 0)
+  set(FULL_LINE_TO_ADD "")
+  while (true)
+string(JSON RES ERROR_VARIABLE ERROR_VAR GET ${API_TEST_CONFIGS} 
${IDX} ${key} ${LIST_IDX})
+   if (${RES} MATCHES .*NOTFOUND)
+  break()
+   endif()
+list(APPEND FULL_LINE_TO_ADD "${RES}")
+MATH(EXPR LIST_IDX "${LIST_IDX} + 1")
+  endwhile()
+  if (NOT "${FULL_LINE_TO_ADD}" STREQUAL "")
+   string (REPLACE ";" ":" FULL_LINE_TO_ADD_STR "${FULL_LINE_TO_ADD}")
+list(APPEND TO_PARAMS "${substr}=${FULL_LINE_TO_ADD_STR}")
+set(TO_PARAMS ${TO_PARAMS} PARENT_SCOPE)
+  endif()
+endfunction()
+
+add_param(test_compiler "test_compiler")
+add_param(test_arch "test_arch")
+add_param(test_simulator "lldb-run-with-simulator")
+add_list_param(extra_flags "extra_flags")
+add_list_param(skip_categories "skip_categories")
+add_list_param(xfail_categories "xfail_categories")
+
+# Create test targets
+if (CHECK_ALL_NEEDED)
+  add_lit_testsuite(${TEST_NAME}  ${TEST_DESC}
+   ${CMAKE_CURRENT_BINARY_DIR}
+   PARAMS ${TO_PARAMS}
+DEPENDS lldb-api-test-deps)
+else()
+  add_lit_testsuite(${TEST_NAME}  ${TEST_DESC}
+   ${CMAKE_CURRENT_BINARY_DIR}
+   PARAMS ${TO_PARAMS}
+EXCLUDE_FROM_CHECK_ALL
+DEPENDS lldb-api-test-deps)
+endif()
+MATH(EXPR IDX "${IDX

[Lldb-commits] [lldb] Add ability to specify running LLDB API testsuite by json description (PR #89764)

2024-04-23 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
7c581b554efa7c720b780f721877107ae0fc78ff...b5e6e4ab15692a5d4ec3e1bc4d04c9c98f572d08
 lldb/packages/Python/lldbsuite/test/dotest.py lldb/test/API/lit.cfg.py
``





View the diff from darker here.


``diff
--- packages/Python/lldbsuite/test/dotest.py2024-04-23 08:33:40.00 +
+++ packages/Python/lldbsuite/test/dotest.py2024-04-23 13:27:12.076722 +
@@ -336,12 +336,12 @@
 )
 
 if args.E:
 args_list = args.E.split(":")
 # Remove first 'start' argument, as we need it was needed to pass as 
argument to '-E'
-if (args_list[0] == "start"):
-  args_list = args_list[1:]
+if args_list[0] == "start":
+args_list = args_list[1:]
 
 os.environ["CFLAGS_EXTRAS"] = " ".join(args_list)
 
 if args.dwarf_version:
 configuration.dwarf_version = args.dwarf_version
--- test/API/lit.cfg.py 2024-04-23 08:33:40.00 +
+++ test/API/lit.cfg.py 2024-04-23 13:27:12.186899 +
@@ -305,11 +305,11 @@
 
 lldb_test_extra_flags = lit_config.params.get("extra_flags")
 if lldb_test_extra_flags:
 # FIXME: dotest does not support several -E options.
 # FIXME: start in the beginning is a workaround to make sure command not 
start with '--'
-dotest_cmd += ["-E", rf'start:{lldb_test_extra_flags}']
+dotest_cmd += ["-E", rf"start:{lldb_test_extra_flags}"]
 
 
 lldb_test_skip_categories = lit_config.params.get("skip_categories")
 if lldb_test_skip_categories:
 for skip_category in lldb_test_skip_categories.split(":"):

``




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


[Lldb-commits] [lldb] [lldb][tests] Add ability to run API tests with qemu-user simulator (PR #89765)

2024-04-23 Thread via lldb-commits

https://github.com/ita-sc created 
https://github.com/llvm/llvm-project/pull/89765

None

>From ec086f99bb6cb48cae02f77e621a51cb29c751d1 Mon Sep 17 00:00:00 2001
From: Ivan Tetyushkin 
Date: Thu, 11 Apr 2024 12:22:19 +0300
Subject: [PATCH] [lldb][tests] Add ability to run API tests with qemu-user
 simulator

---
 lldb/test/API/lit.cfg.py | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 9d6775917e1370..5e5fc750f529d5 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -162,6 +162,9 @@ def delete_module_cache(path):
 elif lldb_use_simulator == "tvos":
 lit_config.note("Running API tests on tvOS simulator")
 config.available_features.add("lldb-simulator-tvos")
+elif lldb_use_simulator == "qemu-user":
+lit_config.note("Running API tests on qemu-user simulator")
+config.available_features.add("lldb-simulator-qemu-user")
 else:
 lit_config.error("Unknown simulator id 
'{}'".format(lldb_use_simulator))
 
@@ -268,6 +271,10 @@ def delete_module_cache(path):
 "tvos-simulator",
 ]
 
+if "lldb-simulator-qemu-user" in config.available_features:
+dotest_cmd += ["--platform-name",
+   "qemu-user"]
+
 if is_configured("enabled_plugins"):
 for plugin in config.enabled_plugins:
 dotest_cmd += ["--enable-plugin", plugin]

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


[Lldb-commits] [lldb] [lldb][tests] Add ability to run API tests with qemu-user simulator (PR #89765)

2024-04-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (ita-sc)


Changes



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


1 Files Affected:

- (modified) lldb/test/API/lit.cfg.py (+7) 


``diff
diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index 9d6775917e1370..5e5fc750f529d5 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -162,6 +162,9 @@ def delete_module_cache(path):
 elif lldb_use_simulator == "tvos":
 lit_config.note("Running API tests on tvOS simulator")
 config.available_features.add("lldb-simulator-tvos")
+elif lldb_use_simulator == "qemu-user":
+lit_config.note("Running API tests on qemu-user simulator")
+config.available_features.add("lldb-simulator-qemu-user")
 else:
 lit_config.error("Unknown simulator id 
'{}'".format(lldb_use_simulator))
 
@@ -268,6 +271,10 @@ def delete_module_cache(path):
 "tvos-simulator",
 ]
 
+if "lldb-simulator-qemu-user" in config.available_features:
+dotest_cmd += ["--platform-name",
+   "qemu-user"]
+
 if is_configured("enabled_plugins"):
 for plugin in config.enabled_plugins:
 dotest_cmd += ["--enable-plugin", plugin]

``




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


[Lldb-commits] [lldb] [lldb][tests] Add ability to run API tests with qemu-user simulator (PR #89765)

2024-04-23 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
7c581b554efa7c720b780f721877107ae0fc78ff...ec086f99bb6cb48cae02f77e621a51cb29c751d1
 lldb/test/API/lit.cfg.py
``





View the diff from darker here.


``diff
--- lit.cfg.py  2024-04-23 08:36:08.00 +
+++ lit.cfg.py  2024-04-23 13:32:17.601728 +
@@ -270,12 +270,11 @@
 "--platform-name",
 "tvos-simulator",
 ]
 
 if "lldb-simulator-qemu-user" in config.available_features:
-dotest_cmd += ["--platform-name",
-   "qemu-user"]
+dotest_cmd += ["--platform-name", "qemu-user"]
 
 if is_configured("enabled_plugins"):
 for plugin in config.enabled_plugins:
 dotest_cmd += ["--enable-plugin", plugin]
 

``




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


[Lldb-commits] [lldb] [lldb][test] Remove restriction for remote working directory (PR #89768)

2024-04-23 Thread via lldb-commits

https://github.com/ita-sc created 
https://github.com/llvm/llvm-project/pull/89768

Hi

This patch removes restriction for remote directory, as some remote targets may 
not have remote working directory, for example baremetal targets.

>From 3472c2b35393d2a7b348e245857ffac3765dc6e3 Mon Sep 17 00:00:00 2001
From: Ivan Tetyushkin 
Date: Thu, 11 Apr 2024 11:52:48 +0300
Subject: [PATCH] [lldb][test] Remove restriction for remote working directory

Some remote targets may not have remote working directory,
for example baremetal targets.
---
 lldb/packages/Python/lldbsuite/test/dotest.py | 4 
 1 file changed, 4 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 2ec4a840b91675..03acb4059591fc 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -1009,10 +1009,6 @@ def run_suite():
 % configuration.lldb_platform_working_dir
 )
 lldb.selected_platform = lldb.remote_platform
-else:
-lldb.remote_platform = None
-configuration.lldb_platform_working_dir = None
-configuration.lldb_platform_url = None
 
 # Set up the working directory.
 # Note that it's not dotest's job to clean this directory.

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


[Lldb-commits] [lldb] [lldb][test] Remove restriction for remote working directory (PR #89768)

2024-04-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (ita-sc)


Changes

Hi

This patch removes restriction for remote directory, as some remote targets may 
not have remote working directory, for example baremetal targets.

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


1 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/dotest.py (-4) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 2ec4a840b91675..03acb4059591fc 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -1009,10 +1009,6 @@ def run_suite():
 % configuration.lldb_platform_working_dir
 )
 lldb.selected_platform = lldb.remote_platform
-else:
-lldb.remote_platform = None
-configuration.lldb_platform_working_dir = None
-configuration.lldb_platform_url = None
 
 # Set up the working directory.
 # Note that it's not dotest's job to clean this directory.

``




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


[Lldb-commits] [lldb] [lldb][Docs] Convert GDB protocol extensions doc to Markdown and add to website (PR #89718)

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

DavidSpickett wrote:

The CI build "worked" but there is this warning:
```
/home/runner/work/llvm-project/llvm-project/lldb/docs/index.rst:146: WARNING: 
toctree contains reference to nonexisting document 'resources/lldbgdbremote'
```
Which is what I expected. Once it knows to look for Markdown it'll find the .md 
file for that.

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


[Lldb-commits] [lldb] [lldb][test] Remove restriction for remote working directory (PR #89768)

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

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

Based on the description it's not entirely clear to me what exactly you're 
trying to achieve. You don't have a working directory, but presumably you still 
have a platform name and a platform URL? In other words, I assume you want to 
go into the `if configuration.lldb_platform_name` case? Please update the 
description. 

Looking at that code in more detail, I think the whole `if 
configuration.lldb_platform_working_dir:` needs to be indented to be part of 
the `if configuration.lldb_platform_name` case. It assumes 
`lldb.remote_platform` which would be None if we didn't create the platform 
above it. 

In other words, I think the logic is supposed to be:

```
if configuration.lldb_platform_name:
  ## Create platform 
  if configuration.lldb_platform_url:
## Connect to platform URL
  else:
configuration.lldb_platform_url = None

  if configuration.lldb_platform_working_dir:
## Set working dir 
  else: 
configuration.lldb_platform_working_dir = Nonej
else:
  lldb.remote_platform = None
  configuration.lldb_platform_name = None 
  configuration.lldb_platform_working_dir = None
  configuration.lldb_platform_url = None
```

The two lines `lldb.remote_platform = None` and 
`configuration.lldb_platform_name = None ` are no-ops as you wouldn't have 
gotten there otherwise, but I think we can keep them to make it clear that 
we're clearing everything. 

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


[Lldb-commits] [lldb] [lldb][test] Remove restriction for remote working directory (PR #89768)

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

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


[Lldb-commits] [lldb] [lldb][test] Remove restriction for remote working directory (PR #89768)

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

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


[Lldb-commits] [lldb] [lldb][tests] Add ability to run API tests with qemu-user simulator (PR #89765)

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

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

LGTM with the formatting fixed.

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


[Lldb-commits] [lldb] [lldb/test] Add basic ld.lld --debug-names tests (PR #88335)

2024-04-23 Thread Adrian Prantl via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Report exit status message in lldb-dap, same as lldb cli (PR #89405)

2024-04-23 Thread via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Enable support for Markdown documentation pages (PR #89716)

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

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

LGTM

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


[Lldb-commits] [lldb] [lldb][Docs] Convert GDB protocol extensions doc to Markdown and add to website (PR #89718)

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

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

The converted markdown looks good to me. I expect this to render very nicely on 
the new website with the table-of-content on the right hand side. Thanks for 
doing this!

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


[Lldb-commits] [lldb] [lldb] Add SB API to access static constexpr member values (PR #89730)

2024-04-23 Thread Alex Langford via lldb-commits


@@ -325,6 +330,79 @@ lldb::SBTypeMemberFunction 
SBType::GetMemberFunctionAtIndex(uint32_t idx) {
   return sb_func_type;
 }
 
+SBTypeStaticField::SBTypeStaticField() { LLDB_INSTRUMENT_VA(this); }
+
+SBTypeStaticField::SBTypeStaticField(lldb_private::CompilerDecl decl)
+: m_opaque_up(decl ? std::make_unique(decl) : nullptr) {}
+
+SBTypeStaticField::SBTypeStaticField(const SBTypeStaticField &rhs) {
+  LLDB_INSTRUMENT_VA(this, rhs);
+
+  m_opaque_up = clone(rhs.m_opaque_up);
+}
+
+SBTypeStaticField &SBTypeStaticField::operator=(const SBTypeStaticField &rhs) {
+  LLDB_INSTRUMENT_VA(this, rhs);
+
+  m_opaque_up = clone(rhs.m_opaque_up);
+  return *this;
+}
+
+SBTypeStaticField::~SBTypeStaticField() { LLDB_INSTRUMENT_VA(this); }
+
+SBTypeStaticField::operator bool() const {
+  LLDB_INSTRUMENT_VA(this);
+
+  return IsValid();
+}
+
+bool SBTypeStaticField::IsValid() const {
+  LLDB_INSTRUMENT_VA(this);
+
+  return m_opaque_up != nullptr;
+}
+
+const char *SBTypeStaticField::GetName() {
+  LLDB_INSTRUMENT_VA(this);
+
+  if (!IsValid())
+return "";
+  return m_opaque_up->GetName().GetCString();
+}
+
+const char *SBTypeStaticField::GetMangledName() {
+  LLDB_INSTRUMENT_VA(this);
+
+  if (!IsValid())
+return "";
+  return m_opaque_up->GetMangledName().GetCString();
+}
+
+SBType SBTypeStaticField::GetType() {
+  LLDB_INSTRUMENT_VA(this);
+
+  if (!IsValid())
+return SBType();
+  return SBType(m_opaque_up->GetType());
+}
+
+SBValue SBTypeStaticField::GetConstantValue(lldb::SBTarget target) {
+  LLDB_INSTRUMENT_VA(this);

bulbazord wrote:

The instrumentation macro is missing `target`.

https://github.com/llvm/llvm-project/pull/89730
___
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 broadcaster class strings away from ConstString (PR #89690)

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

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


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


[Lldb-commits] [lldb] I left some commented code in. This test doesn't run reliably in the different build bots (PR #89637)

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

JDevlieghere wrote:

A potential compromise would be to check that the time is great or equal? 

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


[Lldb-commits] [lldb] Summarize std::string's when created from data. (PR #89110)

2024-04-23 Thread via lldb-commits


@@ -37,6 +37,8 @@ def test_with_run_command(self):
 substrs=["stopped", "stop reason = breakpoint"],
 )
 
+self.runCmd("command script import ./ConvertToDataFormatter.py", 
check=True)

jeffreytan81 wrote:

Instead of changing existing test method to test create from data case, let's 
add a new test method instead so that both default and create from data 
formatters are tested.

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


[Lldb-commits] [lldb] a7e2726 - [lldb/test] Add basic ld.lld --debug-names tests (#88335)

2024-04-23 Thread via lldb-commits

Author: Fangrui Song
Date: 2024-04-23T11:18:05-07:00
New Revision: a7e27260a92b7a40ede0c3ea4035733ea61e6571

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

LOG: [lldb/test] Add basic ld.lld --debug-names tests (#88335)

Test that ld.lld --debug-names (#86508) built per-module index can be
consumed by lldb. This has uncovered a bug during the development of the
lld feature.

Added: 


Modified: 
lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-function.cpp
lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-variable.cpp

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-function.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-function.cpp
index 30143a41d5e734..b9a63525d0711d 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-function.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-function.cpp
@@ -59,6 +59,11 @@
 // RUN: lldb-test symbols --name=not_there --find=function %t | \
 // RUN:   FileCheck --check-prefix=EMPTY %s
 
+/// Test a per-module index built by lld.
+// RUN: ld.lld --debug-names %t.o -o %t
+// RUN: lldb-test symbols --name=foo --find=function --function-flags=base %t 
| \
+// RUN:   FileCheck --check-prefix=BASE %s
+
 // NAMES: Name: .debug_names
 
 // BASE: Found 4 functions:

diff  --git a/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-variable.cpp 
b/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-variable.cpp
index 98b4097cdda01f..e46fa14489d32d 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-variable.cpp
+++ b/lldb/test/Shell/SymbolFile/DWARF/x86/find-basic-variable.cpp
@@ -33,6 +33,11 @@
 // RUN: lldb-test symbols --name=not_there --find=variable %t | \
 // RUN:   FileCheck --check-prefix=EMPTY %s
 
+/// Test a per-module index built by lld.
+// RUN: ld.lld --debug-names %t.o -o %t
+// RUN: lldb-test symbols --name=foo --find=variable --context=context %t | \
+// RUN:   FileCheck --check-prefix=CONTEXT %s
+
 // NAMES: Name: .debug_names
 
 // EMPTY: Found 0 variables:



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


[Lldb-commits] [lldb] [lldb/test] Add basic ld.lld --debug-names tests (PR #88335)

2024-04-23 Thread Fangrui Song via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Switch to llvm::DWARFUnitHeader (PR #89808)

2024-04-23 Thread Alex Langford via lldb-commits

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

These are now close enough that they can be swapped out.

>From 3f3989d3d7b0cd64a08a8c30d4d83e45098a4b44 Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Tue, 23 Apr 2024 12:14:02 -0700
Subject: [PATCH] [lldb] Switch to llvm::DWARFUnitHeader

These are now close enough that they can be swapped out.
---
 .../SymbolFile/DWARF/DWARFCompileUnit.h   |   2 +-
 .../Plugins/SymbolFile/DWARF/DWARFTypeUnit.h  |   6 +-
 .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp| 137 +-
 .../Plugins/SymbolFile/DWARF/DWARFUnit.h  |  68 ++---
 4 files changed, 48 insertions(+), 165 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
index dd130977d4b1fb..b8344f548ac3dc 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
@@ -32,7 +32,7 @@ class DWARFCompileUnit : public DWARFUnit {
 
 private:
   DWARFCompileUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
-   const DWARFUnitHeader &header,
+   const llvm::DWARFUnitHeader &header,
const llvm::DWARFAbbreviationDeclarationSet &abbrevs,
DIERef::Section section, bool is_dwo)
   : DWARFUnit(dwarf, uid, header, abbrevs, section, is_dwo) {}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
index 7b58c632c6c5be..8c1f932d8c7fa4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
@@ -24,15 +24,15 @@ class DWARFTypeUnit : public DWARFUnit {
 
   void Dump(Stream *s) const override;
 
-  uint64_t GetTypeHash() { return m_header.GetTypeHash(); }
+  uint64_t GetTypeHash() { return m_header.getTypeHash(); }
 
-  dw_offset_t GetTypeOffset() { return GetOffset() + m_header.GetTypeOffset(); 
}
+  dw_offset_t GetTypeOffset() { return GetOffset() + m_header.getTypeOffset(); 
}
 
   static bool classof(const DWARFUnit *unit) { return unit->IsTypeUnit(); }
 
 private:
   DWARFTypeUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
-const DWARFUnitHeader &header,
+const llvm::DWARFUnitHeader &header,
 const llvm::DWARFAbbreviationDeclarationSet &abbrevs,
 DIERef::Section section, bool is_dwo)
   : DWARFUnit(dwarf, uid, header, abbrevs, section, is_dwo) {}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index e28036d34b34a6..dabc595427dfa1 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -33,12 +33,12 @@ using namespace lldb_private::plugin::dwarf;
 extern int g_verbose;
 
 DWARFUnit::DWARFUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
- const DWARFUnitHeader &header,
+ const llvm::DWARFUnitHeader &header,
  const llvm::DWARFAbbreviationDeclarationSet &abbrevs,
  DIERef::Section section, bool is_dwo)
 : UserID(uid), m_dwarf(dwarf), m_header(header), m_abbrevs(&abbrevs),
   m_cancel_scopes(false), m_section(section), m_is_dwo(is_dwo),
-  m_has_parsed_non_skeleton_unit(false), m_dwo_id(header.GetDWOId()) {}
+  m_has_parsed_non_skeleton_unit(false), m_dwo_id(header.getDWOId()) {}
 
 DWARFUnit::~DWARFUnit() = default;
 
@@ -345,7 +345,7 @@ void DWARFUnit::ExtractDIEsRWLocked() {
 void DWARFUnit::SetDwoStrOffsetsBase() {
   lldb::offset_t baseOffset = 0;
 
-  if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
+  if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
 if (const auto *contribution =
 entry->getContribution(llvm::DW_SECT_STR_OFFSETS))
   baseOffset = contribution->getOffset();
@@ -489,7 +489,7 @@ ParseListTableHeader(const llvm::DWARFDataExtractor &data, 
uint64_t offset,
 
 void DWARFUnit::SetLoclistsBase(dw_addr_t loclists_base) {
   uint64_t offset = 0;
-  if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
+  if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
 const auto *contribution = entry->getContribution(llvm::DW_SECT_LOCLISTS);
 if (!contribution) {
   GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
@@ -533,7 +533,7 @@ DWARFDataExtractor DWARFUnit::GetLocationData() const {
   DWARFContext &Ctx = GetSymbolFileDWARF().GetDWARFContext();
   const DWARFDataExtractor &data =
   GetVersion() >= 5 ? Ctx.getOrLoadLocListsData() : Ctx.getOrLoadLocData();
-  if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
+  if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
 if (const auto *contribution = entry->g

[Lldb-commits] [lldb] [lldb] Switch to llvm::DWARFUnitHeader (PR #89808)

2024-04-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Alex Langford (bulbazord)


Changes

These are now close enough that they can be swapped out.

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


4 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h (+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h (+3-3) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp (+34-103) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h (+10-58) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
index dd130977d4b1fb..b8344f548ac3dc 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
@@ -32,7 +32,7 @@ class DWARFCompileUnit : public DWARFUnit {
 
 private:
   DWARFCompileUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
-   const DWARFUnitHeader &header,
+   const llvm::DWARFUnitHeader &header,
const llvm::DWARFAbbreviationDeclarationSet &abbrevs,
DIERef::Section section, bool is_dwo)
   : DWARFUnit(dwarf, uid, header, abbrevs, section, is_dwo) {}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
index 7b58c632c6c5be..8c1f932d8c7fa4 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h
@@ -24,15 +24,15 @@ class DWARFTypeUnit : public DWARFUnit {
 
   void Dump(Stream *s) const override;
 
-  uint64_t GetTypeHash() { return m_header.GetTypeHash(); }
+  uint64_t GetTypeHash() { return m_header.getTypeHash(); }
 
-  dw_offset_t GetTypeOffset() { return GetOffset() + m_header.GetTypeOffset(); 
}
+  dw_offset_t GetTypeOffset() { return GetOffset() + m_header.getTypeOffset(); 
}
 
   static bool classof(const DWARFUnit *unit) { return unit->IsTypeUnit(); }
 
 private:
   DWARFTypeUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
-const DWARFUnitHeader &header,
+const llvm::DWARFUnitHeader &header,
 const llvm::DWARFAbbreviationDeclarationSet &abbrevs,
 DIERef::Section section, bool is_dwo)
   : DWARFUnit(dwarf, uid, header, abbrevs, section, is_dwo) {}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index e28036d34b34a6..dabc595427dfa1 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -33,12 +33,12 @@ using namespace lldb_private::plugin::dwarf;
 extern int g_verbose;
 
 DWARFUnit::DWARFUnit(SymbolFileDWARF &dwarf, lldb::user_id_t uid,
- const DWARFUnitHeader &header,
+ const llvm::DWARFUnitHeader &header,
  const llvm::DWARFAbbreviationDeclarationSet &abbrevs,
  DIERef::Section section, bool is_dwo)
 : UserID(uid), m_dwarf(dwarf), m_header(header), m_abbrevs(&abbrevs),
   m_cancel_scopes(false), m_section(section), m_is_dwo(is_dwo),
-  m_has_parsed_non_skeleton_unit(false), m_dwo_id(header.GetDWOId()) {}
+  m_has_parsed_non_skeleton_unit(false), m_dwo_id(header.getDWOId()) {}
 
 DWARFUnit::~DWARFUnit() = default;
 
@@ -345,7 +345,7 @@ void DWARFUnit::ExtractDIEsRWLocked() {
 void DWARFUnit::SetDwoStrOffsetsBase() {
   lldb::offset_t baseOffset = 0;
 
-  if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
+  if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
 if (const auto *contribution =
 entry->getContribution(llvm::DW_SECT_STR_OFFSETS))
   baseOffset = contribution->getOffset();
@@ -489,7 +489,7 @@ ParseListTableHeader(const llvm::DWARFDataExtractor &data, 
uint64_t offset,
 
 void DWARFUnit::SetLoclistsBase(dw_addr_t loclists_base) {
   uint64_t offset = 0;
-  if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
+  if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
 const auto *contribution = entry->getContribution(llvm::DW_SECT_LOCLISTS);
 if (!contribution) {
   GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
@@ -533,7 +533,7 @@ DWARFDataExtractor DWARFUnit::GetLocationData() const {
   DWARFContext &Ctx = GetSymbolFileDWARF().GetDWARFContext();
   const DWARFDataExtractor &data =
   GetVersion() >= 5 ? Ctx.getOrLoadLocListsData() : Ctx.getOrLoadLocData();
-  if (const llvm::DWARFUnitIndex::Entry *entry = m_header.GetIndexEntry()) {
+  if (const llvm::DWARFUnitIndex::Entry *entry = m_header.getIndexEntry()) {
 if (const auto *contribution = entry->getContribution(
 GetVersion() >= 5 ? llvm::DW_SECT_LOCLISTS : 
llvm::DW_SECT_EXT_LOC))
   return DWARFDataExtractor(data, cont

[Lldb-commits] [lldb] [lldb] Switch to llvm::DWARFUnitHeader (PR #89808)

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

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

🥳

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


[Lldb-commits] [lldb] [lldb] Fix crash in SymbolFileCTF::ParseFunctions (PR #89845)

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

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

Make SymbolFileCTF::ParseFunctions resilient against not being able to
resolve the argument or return type of a function. ResolveTypeUID can
fail for a variety of reasons so we should always check its result.

The type that caused the crash was `_Bool` which we didn't recognize 
as a basic type. This commit also fixes the underlying issue and adds
a test.

rdar://126943722

>From 5a4f813590b0ceb3fb00ed737650e37715019e89 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 23 Apr 2024 15:26:30 -0700
Subject: [PATCH 1/2] [lldb] Fix crash in SymbolFileCTF::ParseFunctions

Make SymbolFileCTF::ParseFunctions resilient against not being able to
resolve the argument or return type of a function. ResolveTypeUID can
fail for a variety of reasons so we should always check its result.
---
 lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index 65f5b1a5f1b0a2..73c6982d5fbd3c 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -802,7 +802,8 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {
   }
 
   Type *arg_type = ResolveTypeUID(arg_uid);
-  arg_types.push_back(arg_type->GetFullCompilerType());
+  arg_types.push_back(arg_type ? arg_type->GetFullCompilerType()
+   : CompilerType());
 }
 
 if (symbol) {
@@ -813,8 +814,9 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {
 
   // Create function type.
   CompilerType func_type = m_ast->CreateFunctionType(
-  ret_type->GetFullCompilerType(), arg_types.data(), arg_types.size(),
-  is_variadic, 0, clang::CallingConv::CC_C);
+  ret_type ? ret_type->GetFullCompilerType() : CompilerType(),
+  arg_types.data(), arg_types.size(), is_variadic, 0,
+  clang::CallingConv::CC_C);
   lldb::user_id_t function_type_uid = m_types.size() + 1;
   TypeSP type_sp =
   MakeType(function_type_uid, symbol->GetName(), 0, nullptr,

>From a4bf873cf76d265bed94b26e7534924b7ce5c0bf Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 23 Apr 2024 16:03:26 -0700
Subject: [PATCH 2/2] [lldb] Support _Bool in Compact C Type Format (CTF)

---
 lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp | 2 +-
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 5 -
 lldb/test/API/macosx/ctf/Makefile| 2 +-
 lldb/test/API/macosx/ctf/TestCTF.py  | 1 +
 lldb/test/API/macosx/ctf/test.c  | 3 +++
 5 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index 73c6982d5fbd3c..386ba44c5ea653 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -342,7 +342,7 @@ SymbolFileCTF::CreateInteger(const CTFInteger &ctf_integer) 
{
 
   CompilerType compiler_type = m_ast->GetBasicType(basic_type);
 
-  if (basic_type != eBasicTypeVoid) {
+  if (basic_type != eBasicTypeVoid && basic_type != eBasicTypeBool) {
 // Make sure the type we got is an integer type.
 bool compiler_type_is_signed = false;
 if (!compiler_type.IsIntegerType(compiler_type_is_signed))
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 2621f682011b41..662da313af5989 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -838,8 +838,11 @@ lldb::BasicType 
TypeSystemClang::GetBasicTypeEnumeration(llvm::StringRef name) {
   {"__int128_t", eBasicTypeInt128},
   {"__uint128_t", eBasicTypeUnsignedInt128},
 
-  // Miscellaneous
+  // "bool"
   {"bool", eBasicTypeBool},
+  {"_Bool", eBasicTypeBool},
+
+  // Miscellaneous
   {"float", eBasicTypeFloat},
   {"double", eBasicTypeDouble},
   {"long double", eBasicTypeLongDouble},
diff --git a/lldb/test/API/macosx/ctf/Makefile 
b/lldb/test/API/macosx/ctf/Makefile
index afe6ab1b5db06b..0857e234837e54 100644
--- a/lldb/test/API/macosx/ctf/Makefile
+++ b/lldb/test/API/macosx/ctf/Makefile
@@ -4,7 +4,7 @@ MAKE_DSYM := YES
 ifeq "$(COMPRESS_CTF)" "YES"
COMPRESS := -c
 else
-COMPRESS :=
+   COMPRESS :=
 endif
 
 all: a.out a.ctf
diff --git a/lldb/test/API/macosx/ctf/TestCTF.py 
b/lldb/test/API/macosx/ctf/TestCTF.py
index f5fd29f6ed968f..b0a3b4a7eb985c 100644
--- a/lldb/test/API/macosx/ctf/TestCTF.py
+++ b/lldb/test/API/macosx/ctf/TestCTF.py
@@ -53,6 +53,7 @@ def do_test(self):
 "[2] = 'b'",
 "[3] = 'c'

[Lldb-commits] [lldb] [lldb] Fix crash in SymbolFileCTF::ParseFunctions (PR #89845)

2024-04-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Make SymbolFileCTF::ParseFunctions resilient against not being able to
resolve the argument or return type of a function. ResolveTypeUID can
fail for a variety of reasons so we should always check its result.

The type that caused the crash was `_Bool` which we didn't recognize 
as a basic type. This commit also fixes the underlying issue and adds
a test.

rdar://126943722

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


5 Files Affected:

- (modified) lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp (+6-4) 
- (modified) lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp (+4-1) 
- (modified) lldb/test/API/macosx/ctf/Makefile (+1-1) 
- (modified) lldb/test/API/macosx/ctf/TestCTF.py (+1) 
- (modified) lldb/test/API/macosx/ctf/test.c (+3) 


``diff
diff --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index 65f5b1a5f1b0a2..386ba44c5ea653 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -342,7 +342,7 @@ SymbolFileCTF::CreateInteger(const CTFInteger &ctf_integer) 
{
 
   CompilerType compiler_type = m_ast->GetBasicType(basic_type);
 
-  if (basic_type != eBasicTypeVoid) {
+  if (basic_type != eBasicTypeVoid && basic_type != eBasicTypeBool) {
 // Make sure the type we got is an integer type.
 bool compiler_type_is_signed = false;
 if (!compiler_type.IsIntegerType(compiler_type_is_signed))
@@ -802,7 +802,8 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {
   }
 
   Type *arg_type = ResolveTypeUID(arg_uid);
-  arg_types.push_back(arg_type->GetFullCompilerType());
+  arg_types.push_back(arg_type ? arg_type->GetFullCompilerType()
+   : CompilerType());
 }
 
 if (symbol) {
@@ -813,8 +814,9 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {
 
   // Create function type.
   CompilerType func_type = m_ast->CreateFunctionType(
-  ret_type->GetFullCompilerType(), arg_types.data(), arg_types.size(),
-  is_variadic, 0, clang::CallingConv::CC_C);
+  ret_type ? ret_type->GetFullCompilerType() : CompilerType(),
+  arg_types.data(), arg_types.size(), is_variadic, 0,
+  clang::CallingConv::CC_C);
   lldb::user_id_t function_type_uid = m_types.size() + 1;
   TypeSP type_sp =
   MakeType(function_type_uid, symbol->GetName(), 0, nullptr,
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 2621f682011b41..662da313af5989 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -838,8 +838,11 @@ lldb::BasicType 
TypeSystemClang::GetBasicTypeEnumeration(llvm::StringRef name) {
   {"__int128_t", eBasicTypeInt128},
   {"__uint128_t", eBasicTypeUnsignedInt128},
 
-  // Miscellaneous
+  // "bool"
   {"bool", eBasicTypeBool},
+  {"_Bool", eBasicTypeBool},
+
+  // Miscellaneous
   {"float", eBasicTypeFloat},
   {"double", eBasicTypeDouble},
   {"long double", eBasicTypeLongDouble},
diff --git a/lldb/test/API/macosx/ctf/Makefile 
b/lldb/test/API/macosx/ctf/Makefile
index afe6ab1b5db06b..0857e234837e54 100644
--- a/lldb/test/API/macosx/ctf/Makefile
+++ b/lldb/test/API/macosx/ctf/Makefile
@@ -4,7 +4,7 @@ MAKE_DSYM := YES
 ifeq "$(COMPRESS_CTF)" "YES"
COMPRESS := -c
 else
-COMPRESS :=
+   COMPRESS :=
 endif
 
 all: a.out a.ctf
diff --git a/lldb/test/API/macosx/ctf/TestCTF.py 
b/lldb/test/API/macosx/ctf/TestCTF.py
index f5fd29f6ed968f..b0a3b4a7eb985c 100644
--- a/lldb/test/API/macosx/ctf/TestCTF.py
+++ b/lldb/test/API/macosx/ctf/TestCTF.py
@@ -53,6 +53,7 @@ def do_test(self):
 "[2] = 'b'",
 "[3] = 'c'",
 'u = (i = 1, s = "")',
+'b = false',
 "f = 0x",
 ],
 )
diff --git a/lldb/test/API/macosx/ctf/test.c b/lldb/test/API/macosx/ctf/test.c
index 358006646e766e..a15f7a5161334f 100644
--- a/lldb/test/API/macosx/ctf/test.c
+++ b/lldb/test/API/macosx/ctf/test.c
@@ -1,3 +1,4 @@
+#include 
 #include 
 
 struct ForwardDecl;
@@ -24,6 +25,7 @@ typedef struct MyNestedStruct {
   char a[4];
   MyEnumT e;
   MyUnionT u;
+  _Bool b;
 } MyNestedStructT;
 
 typedef struct MyStruct {
@@ -54,6 +56,7 @@ void populate(MyInt i) {
   foo.n.a[2] = 'c';
   foo.n.a[3] = 'd';
   foo.n.e = eOne;
+  foo.n.b = false;
   foo.f = NULL;
   forward = NULL;
   bar.b = i;

``




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


[Lldb-commits] [lldb] [lldb] Fix crash in SymbolFileCTF::ParseFunctions (PR #89845)

2024-04-23 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
ef5906989ae2004100ff56dc5ab59be2be9d5c99...a4bf873cf76d265bed94b26e7534924b7ce5c0bf
 lldb/test/API/macosx/ctf/TestCTF.py
``





View the diff from darker here.


``diff
--- TestCTF.py  2024-04-23 23:03:26.00 +
+++ TestCTF.py  2024-04-23 23:08:38.049209 +
@@ -51,11 +51,11 @@
 "[0] = 'c'",
 "[1] = 'a'",
 "[2] = 'b'",
 "[3] = 'c'",
 'u = (i = 1, s = "")',
-'b = false',
+"b = false",
 "f = 0x",
 ],
 )
 self.expect("target variable foo.n.i", substrs=["(MyInt) foo.n.i = 1"])
 self.expect(

``




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


[Lldb-commits] [lldb] [lldb] Fix crash in SymbolFileCTF::ParseFunctions (PR #89845)

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

https://github.com/JDevlieghere updated 
https://github.com/llvm/llvm-project/pull/89845

>From 5a4f813590b0ceb3fb00ed737650e37715019e89 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 23 Apr 2024 15:26:30 -0700
Subject: [PATCH 1/2] [lldb] Fix crash in SymbolFileCTF::ParseFunctions

Make SymbolFileCTF::ParseFunctions resilient against not being able to
resolve the argument or return type of a function. ResolveTypeUID can
fail for a variety of reasons so we should always check its result.
---
 lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index 65f5b1a5f1b0a2..73c6982d5fbd3c 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -802,7 +802,8 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {
   }
 
   Type *arg_type = ResolveTypeUID(arg_uid);
-  arg_types.push_back(arg_type->GetFullCompilerType());
+  arg_types.push_back(arg_type ? arg_type->GetFullCompilerType()
+   : CompilerType());
 }
 
 if (symbol) {
@@ -813,8 +814,9 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {
 
   // Create function type.
   CompilerType func_type = m_ast->CreateFunctionType(
-  ret_type->GetFullCompilerType(), arg_types.data(), arg_types.size(),
-  is_variadic, 0, clang::CallingConv::CC_C);
+  ret_type ? ret_type->GetFullCompilerType() : CompilerType(),
+  arg_types.data(), arg_types.size(), is_variadic, 0,
+  clang::CallingConv::CC_C);
   lldb::user_id_t function_type_uid = m_types.size() + 1;
   TypeSP type_sp =
   MakeType(function_type_uid, symbol->GetName(), 0, nullptr,

>From f6e9b1ebe2632bc089ec91e60f32192c4788c2cb Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Tue, 23 Apr 2024 16:03:26 -0700
Subject: [PATCH 2/2] [lldb] Support _Bool in Compact C Type Format (CTF)

---
 lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp | 2 +-
 lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp | 5 -
 lldb/test/API/macosx/ctf/Makefile| 2 +-
 lldb/test/API/macosx/ctf/TestCTF.py  | 1 +
 lldb/test/API/macosx/ctf/test.c  | 3 +++
 5 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index 73c6982d5fbd3c..386ba44c5ea653 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -342,7 +342,7 @@ SymbolFileCTF::CreateInteger(const CTFInteger &ctf_integer) 
{
 
   CompilerType compiler_type = m_ast->GetBasicType(basic_type);
 
-  if (basic_type != eBasicTypeVoid) {
+  if (basic_type != eBasicTypeVoid && basic_type != eBasicTypeBool) {
 // Make sure the type we got is an integer type.
 bool compiler_type_is_signed = false;
 if (!compiler_type.IsIntegerType(compiler_type_is_signed))
diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 2621f682011b41..662da313af5989 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -838,8 +838,11 @@ lldb::BasicType 
TypeSystemClang::GetBasicTypeEnumeration(llvm::StringRef name) {
   {"__int128_t", eBasicTypeInt128},
   {"__uint128_t", eBasicTypeUnsignedInt128},
 
-  // Miscellaneous
+  // "bool"
   {"bool", eBasicTypeBool},
+  {"_Bool", eBasicTypeBool},
+
+  // Miscellaneous
   {"float", eBasicTypeFloat},
   {"double", eBasicTypeDouble},
   {"long double", eBasicTypeLongDouble},
diff --git a/lldb/test/API/macosx/ctf/Makefile 
b/lldb/test/API/macosx/ctf/Makefile
index afe6ab1b5db06b..0857e234837e54 100644
--- a/lldb/test/API/macosx/ctf/Makefile
+++ b/lldb/test/API/macosx/ctf/Makefile
@@ -4,7 +4,7 @@ MAKE_DSYM := YES
 ifeq "$(COMPRESS_CTF)" "YES"
COMPRESS := -c
 else
-COMPRESS :=
+   COMPRESS :=
 endif
 
 all: a.out a.ctf
diff --git a/lldb/test/API/macosx/ctf/TestCTF.py 
b/lldb/test/API/macosx/ctf/TestCTF.py
index f5fd29f6ed968f..fed3a8886dd30c 100644
--- a/lldb/test/API/macosx/ctf/TestCTF.py
+++ b/lldb/test/API/macosx/ctf/TestCTF.py
@@ -53,6 +53,7 @@ def do_test(self):
 "[2] = 'b'",
 "[3] = 'c'",
 'u = (i = 1, s = "")',
+"b = false",
 "f = 0x",
 ],
 )
diff --git a/lldb/test/API/macosx/ctf/test.c b/lldb/test/API/macosx/ctf/test.c
index 358006646e766e..a15f7a5161334f 100644
--- a/lldb/test/API/macosx/ctf/test.c
+++ b/lldb/test/API/macosx/ctf/test.c
@@ -1,3 +1,4 @@
+#include 
 #includ

[Lldb-commits] [lldb] [lldb] Fix crash in SymbolFileCTF::ParseFunctions (PR #89845)

2024-04-23 Thread Alex Langford via lldb-commits

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

Makes sense to me.

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


[Lldb-commits] [lldb] fd4399c - [lldb] Fix crash in SymbolFileCTF::ParseFunctions (#89845)

2024-04-23 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2024-04-23T16:50:22-07:00
New Revision: fd4399cb11f4069888bc7eac01f74493b5a2af48

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

LOG: [lldb] Fix crash in SymbolFileCTF::ParseFunctions (#89845)

Make SymbolFileCTF::ParseFunctions resilient against not being able to
resolve the argument or return type of a function. ResolveTypeUID can
fail for a variety of reasons so we should always check its result.

The type that caused the crash was `_Bool` which we didn't recognize 
as a basic type. This commit also fixes the underlying issue and adds
a test.

rdar://126943722

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/test/API/macosx/ctf/Makefile
lldb/test/API/macosx/ctf/TestCTF.py
lldb/test/API/macosx/ctf/test.c

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp 
b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
index 65f5b1a5f1b0a2..386ba44c5ea653 100644
--- a/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
+++ b/lldb/source/Plugins/SymbolFile/CTF/SymbolFileCTF.cpp
@@ -342,7 +342,7 @@ SymbolFileCTF::CreateInteger(const CTFInteger &ctf_integer) 
{
 
   CompilerType compiler_type = m_ast->GetBasicType(basic_type);
 
-  if (basic_type != eBasicTypeVoid) {
+  if (basic_type != eBasicTypeVoid && basic_type != eBasicTypeBool) {
 // Make sure the type we got is an integer type.
 bool compiler_type_is_signed = false;
 if (!compiler_type.IsIntegerType(compiler_type_is_signed))
@@ -802,7 +802,8 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {
   }
 
   Type *arg_type = ResolveTypeUID(arg_uid);
-  arg_types.push_back(arg_type->GetFullCompilerType());
+  arg_types.push_back(arg_type ? arg_type->GetFullCompilerType()
+   : CompilerType());
 }
 
 if (symbol) {
@@ -813,8 +814,9 @@ size_t SymbolFileCTF::ParseFunctions(CompileUnit &cu) {
 
   // Create function type.
   CompilerType func_type = m_ast->CreateFunctionType(
-  ret_type->GetFullCompilerType(), arg_types.data(), arg_types.size(),
-  is_variadic, 0, clang::CallingConv::CC_C);
+  ret_type ? ret_type->GetFullCompilerType() : CompilerType(),
+  arg_types.data(), arg_types.size(), is_variadic, 0,
+  clang::CallingConv::CC_C);
   lldb::user_id_t function_type_uid = m_types.size() + 1;
   TypeSP type_sp =
   MakeType(function_type_uid, symbol->GetName(), 0, nullptr,

diff  --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp 
b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
index 2621f682011b41..662da313af5989 100644
--- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -838,8 +838,11 @@ lldb::BasicType 
TypeSystemClang::GetBasicTypeEnumeration(llvm::StringRef name) {
   {"__int128_t", eBasicTypeInt128},
   {"__uint128_t", eBasicTypeUnsignedInt128},
 
-  // Miscellaneous
+  // "bool"
   {"bool", eBasicTypeBool},
+  {"_Bool", eBasicTypeBool},
+
+  // Miscellaneous
   {"float", eBasicTypeFloat},
   {"double", eBasicTypeDouble},
   {"long double", eBasicTypeLongDouble},

diff  --git a/lldb/test/API/macosx/ctf/Makefile 
b/lldb/test/API/macosx/ctf/Makefile
index afe6ab1b5db06b..0857e234837e54 100644
--- a/lldb/test/API/macosx/ctf/Makefile
+++ b/lldb/test/API/macosx/ctf/Makefile
@@ -4,7 +4,7 @@ MAKE_DSYM := YES
 ifeq "$(COMPRESS_CTF)" "YES"
COMPRESS := -c
 else
-COMPRESS :=
+   COMPRESS :=
 endif
 
 all: a.out a.ctf

diff  --git a/lldb/test/API/macosx/ctf/TestCTF.py 
b/lldb/test/API/macosx/ctf/TestCTF.py
index f5fd29f6ed968f..fed3a8886dd30c 100644
--- a/lldb/test/API/macosx/ctf/TestCTF.py
+++ b/lldb/test/API/macosx/ctf/TestCTF.py
@@ -53,6 +53,7 @@ def do_test(self):
 "[2] = 'b'",
 "[3] = 'c'",
 'u = (i = 1, s = "")',
+"b = false",
 "f = 0x",
 ],
 )

diff  --git a/lldb/test/API/macosx/ctf/test.c b/lldb/test/API/macosx/ctf/test.c
index 358006646e766e..a15f7a5161334f 100644
--- a/lldb/test/API/macosx/ctf/test.c
+++ b/lldb/test/API/macosx/ctf/test.c
@@ -1,3 +1,4 @@
+#include 
 #include 
 
 struct ForwardDecl;
@@ -24,6 +25,7 @@ typedef struct MyNestedStruct {
   char a[4];
   MyEnumT e;
   MyUnionT u;
+  _Bool b;
 } MyNestedStructT;
 
 typedef struct MyStruct {
@@ -54,6 +56,7 @@ void populate(MyInt i) {
   foo.n.a[2] = 'c';
   foo.n.a[3] = 'd';
   foo.n.e = eOne;
+  foo.n.b = false;
   foo.f = NULL;
   forward = NULL;
   bar.b = i;



__

[Lldb-commits] [lldb] [lldb] Fix crash in SymbolFileCTF::ParseFunctions (PR #89845)

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

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


[Lldb-commits] [lldb] I left some commented code in. This test doesn't run reliably in the different build bots (PR #89637)

2024-04-23 Thread Fred Grim via lldb-commits

feg208 wrote:

> A potential compromise would be to check that the time is great or equal?

That's a good idea. I'll make that change and add a note

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


[Lldb-commits] [lldb] I left some commented code in. This test doesn't run reliably in the different build bots (PR #89637)

2024-04-23 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

Hi @feg208 , I noticed that your [previous commit 
](https://github.com/llvm/llvm-project/pull/89267) has a very.. unusual commit 
title and message. The same thing applies to this PR.

I'd appreciate it if you could follow a more standard commit title and message, 
so that the logs are more easily parseable.
Here's the official LLVM docs on the matter: 
https://llvm.org/docs/DeveloperPolicy.html#commit-messages

You can also get a good sample by doing a `git log --one-line` inside the llvm 
repo.

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


[Lldb-commits] [lldb] Allow multiple destroy callbacks in `SBDebugger::SetDestroyCallback()` (PR #89868)

2024-04-23 Thread via lldb-commits

https://github.com/royitaqi created 
https://github.com/llvm/llvm-project/pull/89868

# Motivation

Individual callers of `SBDebugger::SetDestroyCallback()` might think that they 
have registered their callback and expect it to be called when the debugger is 
destroyed. In reality, only the last caller survives, and all previous callers 
are forgotten, which might be a surprise to them. Worse, if this is called in a 
race condition, which callback survives is less predictable, which may case 
confusing behavior elsewhere.

# This PR

Allows multiple destroy callbacks to be registered and all called when the 
debugger is destroyed.

## Semantic change to `SetDestroyCallback()` 

Currently, the method overwrites the old callback with the new one. With this 
PR, it will NOT overwrite. Instead, it will hold on to both. Both callbacks get 
called during destroy.

**Risk**: Although the documentation of `SetDestroyCallback()` (see 
[C++](https://lldb.llvm.org/cpp_reference/classlldb_1_1SBDebugger.html#afa1649d9453a376b5c95888b5a0cb4ec)
 and 
[python](https://lldb.llvm.org/python_api/lldb.SBDebugger.html#lldb.SBDebugger.SetDestroyCallback))
 doesn't really specify the behavior, there is a risk: if existing call sites 
rely on the "overwrite" behavior, they will be surprised because now the old 
callback will get called.  But as the above said, the current behavior of 
"overwrite" itself might be unintended, so I don't anticipate users to rely on 
this behavior. In short, this risk might be less of a problem if we correct it 
sooner rather than later (which is what this PR is trying to do).

## Implementation

The implementation holds a `std::vector>`. When 
`SetDestroyCallback()` is called, callbacks and batons are appended to the 
`std::vector`. When destroy event happen, the `(callback, baton)` pairs are 
invoked FIFO. Finally, the `std::vector` is cleared.

# Other considerations

Instead of changing `SetDestroyCallback()`, a new method `AddDestroyCallback()` 
can be added, which use the same `std::vector>` implementation. 
Together with `ClearDestroyCallback()` (see below), they will replace and 
deprecate `SetDestroyCallback()`. Meanwhile, in order to be backward 
compatible, `SetDestroyCallback()` need to be updated to clear the 
`std::vector` and then add the new callback. Pros: The end state is 
semantically more correct. Cons: More steps to take; potentially maintaining an 
"incorrect" behavior (of "overwrite").

A new method `ClearDestroyCallback()` can be added. Might be unnecessary at 
this point, because workflows which need to set then clear callbacks may exist 
but shouldn't be too common at least for now. Such method can be added later 
when needed.

The `std::vector` may bring slight performance drawback if its implementation 
doesn't handle small size efficiently. However, even if that's the case, this 
path should be very cold (only used during init and destroy). Such performance 
drawback should be negligible.

A different implementation was also considered. Instead of using `std::vector`, 
the current `m_destroy_callback` field can be kept unchanged. When 
`SetDestroyCallback()` is called, a lambda function can be stored into 
`m_destroy_callback`. This lambda function will first call the old callback, 
then the new one. This way, `std::vector` is avoided. However, this 
implementation is more complex, thus less readable, with not much perf to gain.

>From 079a550481d4cdcb69ad01c376b5e1f0632a07d6 Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Tue, 23 Apr 2024 18:10:21 -0700
Subject: [PATCH] Allow multiple destroy callbacks in
 `SBDebugger::SetDestroyCallback()`

---
 lldb/include/lldb/Core/Debugger.h |  4 ++--
 lldb/source/Core/Debugger.cpp | 10 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 418c2403d020f4..20884f954ec7db 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -731,8 +731,8 @@ class Debugger : public 
std::enable_shared_from_this,
   lldb::TargetSP m_dummy_target_sp;
   Diagnostics::CallbackID m_diagnostics_callback_id;
 
-  lldb_private::DebuggerDestroyCallback m_destroy_callback = nullptr;
-  void *m_destroy_callback_baton = nullptr;
+  std::vector>
+   m_destroy_callback_and_baton;
 
   uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
   std::mutex m_interrupt_mutex;
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 19b3cf3bbf46b1..0ebdf2b0a0f970 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -743,10 +743,11 @@ DebuggerSP 
Debugger::CreateInstance(lldb::LogOutputCallback log_callback,
 }
 
 void Debugger::HandleDestroyCallback() {
-  if (m_destroy_callback) {
-m_destroy_callback(GetID(), m_destroy_callback_baton);
-m_destroy_callback = nullptr;
+  const lldb::user_id_t user_id = GetID();
+  for (const auto &callback_and_baton : m_dest

[Lldb-commits] [lldb] Allow multiple destroy callbacks in `SBDebugger::SetDestroyCallback()` (PR #89868)

2024-04-23 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[Lldb-commits] [lldb] Allow multiple destroy callbacks in `SBDebugger::SetDestroyCallback()` (PR #89868)

2024-04-23 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (royitaqi)


Changes

# Motivation

Individual callers of `SBDebugger::SetDestroyCallback()` might think that they 
have registered their callback and expect it to be called when the debugger is 
destroyed. In reality, only the last caller survives, and all previous callers 
are forgotten, which might be a surprise to them. Worse, if this is called in a 
race condition, which callback survives is less predictable, which may case 
confusing behavior elsewhere.

# This PR

Allows multiple destroy callbacks to be registered and all called when the 
debugger is destroyed.

## Semantic change to `SetDestroyCallback()` 

Currently, the method overwrites the old callback with the new one. With this 
PR, it will NOT overwrite. Instead, it will hold on to both. Both callbacks get 
called during destroy.

**Risk**: Although the documentation of `SetDestroyCallback()` (see 
[C++](https://lldb.llvm.org/cpp_reference/classlldb_1_1SBDebugger.html#afa1649d9453a376b5c95888b5a0cb4ec)
 and 
[python](https://lldb.llvm.org/python_api/lldb.SBDebugger.html#lldb.SBDebugger.SetDestroyCallback))
 doesn't really specify the behavior, there is a risk: if existing call sites 
rely on the "overwrite" behavior, they will be surprised because now the old 
callback will get called.  But as the above said, the current behavior of 
"overwrite" itself might be unintended, so I don't anticipate users to rely on 
this behavior. In short, this risk might be less of a problem if we correct it 
sooner rather than later (which is what this PR is trying to do).

## Implementation

The implementation holds a `std::vector>`. When `SetDestroyCallback()` is called, callbacks and batons are 
appended to the `std::vector`. When destroy event happen, the `(callback, 
baton)` pairs are invoked FIFO. Finally, the `std::vector` is cleared.

# Other considerations

Instead of changing `SetDestroyCallback()`, a new method `AddDestroyCallback()` 
can be added, which use the same `std::vector>` 
implementation. Together with `ClearDestroyCallback()` (see below), they will 
replace and deprecate `SetDestroyCallback()`. Meanwhile, in order to be 
backward compatible, `SetDestroyCallback()` need to be updated to clear the 
`std::vector` and then add the new callback. Pros: The end state is 
semantically more correct. Cons: More steps to take; potentially maintaining an 
"incorrect" behavior (of "overwrite").

A new method `ClearDestroyCallback()` can be added. Might be unnecessary at 
this point, because workflows which need to set then clear callbacks may exist 
but shouldn't be too common at least for now. Such method can be added later 
when needed.

The `std::vector` may bring slight performance drawback if its implementation 
doesn't handle small size efficiently. However, even if that's the case, this 
path should be very cold (only used during init and destroy). Such performance 
drawback should be negligible.

A different implementation was also considered. Instead of using `std::vector`, 
the current `m_destroy_callback` field can be kept unchanged. When 
`SetDestroyCallback()` is called, a lambda function can be stored into 
`m_destroy_callback`. This lambda function will first call the old callback, 
then the new one. This way, `std::vector` is avoided. However, this 
implementation is more complex, thus less readable, with not much perf to gain.

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


2 Files Affected:

- (modified) lldb/include/lldb/Core/Debugger.h (+2-2) 
- (modified) lldb/source/Core/Debugger.cpp (+5-5) 


``diff
diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 418c2403d020f4..20884f954ec7db 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -731,8 +731,8 @@ class Debugger : public 
std::enable_shared_from_this,
   lldb::TargetSP m_dummy_target_sp;
   Diagnostics::CallbackID m_diagnostics_callback_id;
 
-  lldb_private::DebuggerDestroyCallback m_destroy_callback = nullptr;
-  void *m_destroy_callback_baton = nullptr;
+  std::vector>
+   m_destroy_callback_and_baton;
 
   uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
   std::mutex m_interrupt_mutex;
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 19b3cf3bbf46b1..0ebdf2b0a0f970 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -743,10 +743,11 @@ DebuggerSP 
Debugger::CreateInstance(lldb::LogOutputCallback log_callback,
 }
 
 void Debugger::HandleDestroyCallback() {
-  if (m_destroy_callback) {
-m_destroy_callback(GetID(), m_destroy_callback_baton);
-m_destroy_callback = nullptr;
+  const lldb::user_id_t user_id = GetID();
+  for (const auto &callback_and_baton : m_destroy_callback_and_baton) {
+callback_and_baton.first(user_id, callback_and_baton.second);
   }
+  m_destroy_callback_

[Lldb-commits] [lldb] Allow multiple destroy callbacks in `SBDebugger::SetDestroyCallback()` (PR #89868)

2024-04-23 Thread via lldb-commits

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


[Lldb-commits] [lldb] Allow multiple destroy callbacks in `SBDebugger::SetDestroyCallback()` (PR #89868)

2024-04-23 Thread via lldb-commits

https://github.com/royitaqi updated 
https://github.com/llvm/llvm-project/pull/89868

>From 079a550481d4cdcb69ad01c376b5e1f0632a07d6 Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Tue, 23 Apr 2024 18:10:21 -0700
Subject: [PATCH 1/2] Allow multiple destroy callbacks in
 `SBDebugger::SetDestroyCallback()`

---
 lldb/include/lldb/Core/Debugger.h |  4 ++--
 lldb/source/Core/Debugger.cpp | 10 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 418c2403d020f4..20884f954ec7db 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -731,8 +731,8 @@ class Debugger : public 
std::enable_shared_from_this,
   lldb::TargetSP m_dummy_target_sp;
   Diagnostics::CallbackID m_diagnostics_callback_id;
 
-  lldb_private::DebuggerDestroyCallback m_destroy_callback = nullptr;
-  void *m_destroy_callback_baton = nullptr;
+  std::vector>
+   m_destroy_callback_and_baton;
 
   uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
   std::mutex m_interrupt_mutex;
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 19b3cf3bbf46b1..0ebdf2b0a0f970 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -743,10 +743,11 @@ DebuggerSP 
Debugger::CreateInstance(lldb::LogOutputCallback log_callback,
 }
 
 void Debugger::HandleDestroyCallback() {
-  if (m_destroy_callback) {
-m_destroy_callback(GetID(), m_destroy_callback_baton);
-m_destroy_callback = nullptr;
+  const lldb::user_id_t user_id = GetID();
+  for (const auto &callback_and_baton : m_destroy_callback_and_baton) {
+callback_and_baton.first(user_id, callback_and_baton.second);
   }
+  m_destroy_callback_and_baton.clear();
 }
 
 void Debugger::Destroy(DebuggerSP &debugger_sp) {
@@ -1427,8 +1428,7 @@ void Debugger::SetLoggingCallback(lldb::LogOutputCallback 
log_callback,
 
 void Debugger::SetDestroyCallback(
 lldb_private::DebuggerDestroyCallback destroy_callback, void *baton) {
-  m_destroy_callback = destroy_callback;
-  m_destroy_callback_baton = baton;
+  m_destroy_callback_and_baton.emplace_back(destroy_callback, baton);
 }
 
 static void PrivateReportProgress(Debugger &debugger, uint64_t progress_id,

>From 771b52723be8d0ffecaf8f0818105cfdb82ba332 Mon Sep 17 00:00:00 2001
From: Roy Shi 
Date: Tue, 23 Apr 2024 21:05:58 -0700
Subject: [PATCH 2/2] Fix code format

---
 lldb/include/lldb/Core/Debugger.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/include/lldb/Core/Debugger.h 
b/lldb/include/lldb/Core/Debugger.h
index 20884f954ec7db..af025219b0bc12 100644
--- a/lldb/include/lldb/Core/Debugger.h
+++ b/lldb/include/lldb/Core/Debugger.h
@@ -732,7 +732,7 @@ class Debugger : public 
std::enable_shared_from_this,
   Diagnostics::CallbackID m_diagnostics_callback_id;
 
   std::vector>
-   m_destroy_callback_and_baton;
+  m_destroy_callback_and_baton;
 
   uint32_t m_interrupt_requested = 0; ///< Tracks interrupt requests
   std::mutex m_interrupt_mutex;

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


[Lldb-commits] [lldb] Allow multiple destroy callbacks in `SBDebugger::SetDestroyCallback()` (PR #89868)

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

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

Can you elaborate a bit more about why you want to change the behavior? Your 
motivation touches on the fact that it might be surprising or racy. While I 
think having the ability to register multiple callbacks makes sense, I'm not 
sure I agree with either.

 - The method is called `SetDestroyCallback` which makes it pretty clear that 
it's a setter, which is generally expected to change the value, rather than add 
to it. If the method had been called `AddDestroyCallback` on the other hand, I 
would expect it to add the callback rather than overwrite it. 
 - I don't think there's anything racy about a setter. Even if it were, nothing 
in this PR addresses the racy-ness.

The setter also makes it possible to remove a callback by overwriting it with a 
callback that does nothing. With the current approach that's no longer 
possible. I'm not sure if that's important, but something to consider. 

If the goal is to be able to specify multiple callbacks, a potential solution 
could be to store the callbacks in a list as you do in this PR, but add a new 
method `AddDestroyCallback` which appends to the list. We could keep the 
existing behavior for `SetDestroyCallback` by clearing the list and adding it 
as the first entry. That would also solve the problem of not being able to 
remove existing callbacks. 

Regardless of the direction, this definitely needs a corresponding test and 
updated documentation. 

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