[Lldb-commits] [lldb] 6c3232b - [lldb][Docs] Add simpler "automatic" cross-compile option to build docs (#65311)

2023-09-06 Thread via lldb-commits

Author: David Spickett
Date: 2023-09-06T08:48:19+01:00
New Revision: 6c3232b5150ffcca8d90ab364272323bb82655fb

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

LOG: [lldb][Docs] Add simpler "automatic" cross-compile option to build docs 
(#65311)

The main way I cross build lldb is to point CMake at an existing host
build to get the native tablegen tools. This is what we had documented
before.

There is another option where you start from scratch and the host tools
are built for you. This patch documents that and explains which one to
choose.

Added another arm64 example which uses this. So the frst one is the
"automatic" build and the second is the traditional approach.

For ease of copy paste and understanding, I've kept the full command in
each section and noted the one difference between them.

Along the way I updated some of the preamble to explain the two
approaches and updated some language e.g. removing "just ...". Eveyone's
"just" is different, doubly so when cross-compiling.

Added: 


Modified: 
lldb/docs/resources/build.rst

Removed: 




diff  --git a/lldb/docs/resources/build.rst b/lldb/docs/resources/build.rst
index 25ba3bfc4e84a4..b405a20e239912 100644
--- a/lldb/docs/resources/build.rst
+++ b/lldb/docs/resources/build.rst
@@ -427,10 +427,10 @@ of CMake at this time. Please refer to `CMake's 
documentation 

[Lldb-commits] [lldb] [lldb][Docs] Add simpler "automatic" cross-compile option to build docs (PR #65311)

2023-09-06 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][Docs] Add page about debugging lldb itself (PR #65332)

2023-09-06 Thread David Spickett via lldb-commits

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

>From 5b094742811697096f6e614eca28b0ca5729dc4c Mon Sep 17 00:00:00 2001
From: David Spickett 
Date: Tue, 5 Sep 2023 15:04:05 +0100
Subject: [PATCH 1/3] [lldb][Docs] Add page about debugging lldb itself

We have docs about how to use lldb on other programs,
this tells you how to use lldb on ldlb and lldb-server.

Lacking any Mac experience I've not included any debugserver
information apart from stating it will be similar but not
the same.

I plan for this page to include sections on debugging tests
and other things but this initial commit is purely about
the two main binaries involved.
---
 lldb/docs/index.rst|   1 +
 lldb/docs/resources/debugging-lldb.rst | 254 +
 2 files changed, 255 insertions(+)
 create mode 100644 lldb/docs/resources/debugging-lldb.rst

diff --git a/lldb/docs/index.rst b/lldb/docs/index.rst
index e12a4569cfdd2e..500800d4eaa1c0 100644
--- a/lldb/docs/index.rst
+++ b/lldb/docs/index.rst
@@ -148,6 +148,7 @@ interesting areas to contribute to lldb.
resources/contributing
resources/build
resources/test
+   resources/debugging-lldb
resources/fuzzing
resources/sbapi
resources/extensions
diff --git a/lldb/docs/resources/debugging-lldb.rst 
b/lldb/docs/resources/debugging-lldb.rst
new file mode 100644
index 00..7d49b1cdad7e4c
--- /dev/null
+++ b/lldb/docs/resources/debugging-lldb.rst
@@ -0,0 +1,254 @@
+Debugging LLDB
+==
+
+This page details various ways to debug LLDB itself and other LLDB tools. If
+you want to know how to use LLDB in general, please refer to
+:doc:`/use/tutorial`.
+
+As LLDB is generally split into 2 tools, ``lldb`` and ``lldb-server``
+(``debugserver`` on Mac OS), the techniques shown here will not always apply to
+both. With some knowledge of them all, you can mix and match as needed.
+
+In this document we refer to the initial ``lldb`` as the debugger and the
+program being debugged as the debugee.
+
+Building For Debugging
+--
+
+To build LLDB with debugging information add the following to your CMake
+configuration:
+
+::
+
+  -DCMAKE_BUILD_TYPE=Debug \
+  -DLLDB_EXPORT_ALL_SYMBOLS=1
+
+Note that the ``lldb`` you will use to do the debugging does not itself need to
+have debug information.
+
+Then build as you normally would.
+
+Debugging ``lldb``
+--
+
+The simplest scenario is where we want to debug a local execution of ``lldb``
+like this one:
+
+::
+
+  ./bin/lldb test_program
+
+LLDB is like any other program, so you can use the same approach.
+
+::
+
+  ./bin/lldb -- ./bin/lldb /tmp/test.o
+
+That's it. At least, that's the minimum. There's nothing special about LLDB
+being a debugger that means you can't attach another debugger to it like any
+other program.
+
+What can be an issue is that both debuggers have command line interfaces which
+makes it very confusing which one is which:
+
+::
+
+  (the debugger)
+  (lldb) run
+  Process 1741640 launched: '<...>/bin/lldb' (aarch64)
+  Process 1741640 stopped and restarted: thread 1 received signal: SIGCHLD
+
+  (the debugee)
+  (lldb) target create "/tmp/test.o"
+  Current executable set to '/tmp/test.o' (aarch64).
+
+Another issue is that when you resume the debugee, it will not print the
+``(lldb)`` prompt because as far as it knows it hasn't changed state. A quick
+way around that is to type something that is clearly not a command and hit
+enter.
+
+::
+
+  (lldb) Process 1742266 stopped and restarted: thread 1 received signal: 
SIGCHLD
+  Process 1742266 stopped
+  * thread #1, name = 'lldb', stop reason = signal SIGSTOP
+  frame #0: 0xed5bfbf0 libc.so.6`__GI___libc_read at read.c:26:10
+  (lldb) c
+  Process 1742266 resuming
+  notacommand
+  error: 'notacommand' is not a valid command.
+  (lldb)
+
+You could just remember whether you are in the debugger or the debugee but
+it's thinking overhead, and for interrupt based events you simply may not be
+able to know.
+
+Here are some better approaches. First, you could use another debugger like GDB
+to debug LLDB. Perhaps an IDE like XCode or Visual Studio Code. Something which
+runs LLDB under the hood so you don't have to type in commands to the debugger
+yourself.
+
+Or you could change the prompt text for the debugger and/or debugee.
+
+::
+
+  $ ./bin/lldb -o "settings set prompt \"(lldb debugger) \"" -- \
+./bin/lldb -o "settings set prompt \"(lldb debuggee) \"" /tmp/test.o
+  <...>
+  (lldb) settings set prompt "(lldb debugger) "
+  (lldb debugger) run
+  <...>
+  (lldb) settings set prompt "(lldb debuggee) "
+  (lldb debuggee)
+
+If you want spacial separation you can run the debugee in one terminal then
+attach to it in another. Remember that while paused in the debugger, the 
debugee
+will not respond to input so you will have to ``continue`` in the debugger
+first.
+
+::
+
+  (in terminal A)
+  $ ./bin/lldb /tmp/test.o
+
+

[Lldb-commits] [lldb] [lldb][Docs] Add page about debugging lldb itself (PR #65332)

2023-09-06 Thread David Spickett via lldb-commits


@@ -0,0 +1,254 @@
+Debugging LLDB

DavidSpickett wrote:

I've renamed it just "Debugging". Assuming people read the first sentence it'll 
be clear it's about debugging lldb itself.

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


[Lldb-commits] [lldb] [lldb][Docs] Add page about debugging lldb itself (PR #65332)

2023-09-06 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][Docs] Add page about debugging lldb itself (PR #65332)

2023-09-06 Thread David Spickett via lldb-commits


@@ -0,0 +1,254 @@
+Debugging LLDB
+==
+
+This page details various ways to debug LLDB itself and other LLDB tools. If
+you want to know how to use LLDB in general, please refer to
+:doc:`/use/tutorial`.
+
+As LLDB is generally split into 2 tools, ``lldb`` and ``lldb-server``
+(``debugserver`` on Mac OS), the techniques shown here will not always apply to
+both. With some knowledge of them all, you can mix and match as needed.
+
+In this document we refer to the initial ``lldb`` as the debugger and the
+program being debugged as the debugee.
+
+Building For Debugging
+--
+
+To build LLDB with debugging information add the following to your CMake
+configuration:
+
+::
+
+  -DCMAKE_BUILD_TYPE=Debug \
+  -DLLDB_EXPORT_ALL_SYMBOLS=1
+
+Note that the ``lldb`` you will use to do the debugging does not itself need to
+have debug information.
+
+Then build as you normally would.

DavidSpickett wrote:

Done.

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


[Lldb-commits] [lldb] [lldb][Docs] Add page about debugging lldb itself (PR #65332)

2023-09-06 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][Docs] Add page about debugging lldb itself (PR #65332)

2023-09-06 Thread David Spickett via lldb-commits


@@ -0,0 +1,254 @@
+Debugging LLDB
+==
+
+This page details various ways to debug LLDB itself and other LLDB tools. If
+you want to know how to use LLDB in general, please refer to
+:doc:`/use/tutorial`.
+
+As LLDB is generally split into 2 tools, ``lldb`` and ``lldb-server``
+(``debugserver`` on Mac OS), the techniques shown here will not always apply to
+both. With some knowledge of them all, you can mix and match as needed.
+
+In this document we refer to the initial ``lldb`` as the debugger and the
+program being debugged as the debugee.

DavidSpickett wrote:

Replaced "debugee" with "inferior", since it's only me that seems to use that.

(I always thought "inferior" sounded like a bit severe)

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


[Lldb-commits] [lldb] [lldb][Docs] Add page about debugging lldb itself (PR #65332)

2023-09-06 Thread David Spickett via lldb-commits


@@ -0,0 +1,254 @@
+Debugging LLDB
+==
+
+This page details various ways to debug LLDB itself and other LLDB tools. If
+you want to know how to use LLDB in general, please refer to
+:doc:`/use/tutorial`.
+
+As LLDB is generally split into 2 tools, ``lldb`` and ``lldb-server``
+(``debugserver`` on Mac OS), the techniques shown here will not always apply to
+both. With some knowledge of them all, you can mix and match as needed.
+
+In this document we refer to the initial ``lldb`` as the debugger and the
+program being debugged as the debugee.
+
+Building For Debugging
+--
+
+To build LLDB with debugging information add the following to your CMake
+configuration:
+
+::
+
+  -DCMAKE_BUILD_TYPE=Debug \
+  -DLLDB_EXPORT_ALL_SYMBOLS=1
+
+Note that the ``lldb`` you will use to do the debugging does not itself need to
+have debug information.
+
+Then build as you normally would.
+
+Debugging ``lldb``
+--
+
+The simplest scenario is where we want to debug a local execution of ``lldb``
+like this one:
+
+::
+
+  ./bin/lldb test_program
+
+LLDB is like any other program, so you can use the same approach.
+
+::
+
+  ./bin/lldb -- ./bin/lldb /tmp/test.o
+
+That's it. At least, that's the minimum. There's nothing special about LLDB
+being a debugger that means you can't attach another debugger to it like any
+other program.
+
+What can be an issue is that both debuggers have command line interfaces which
+makes it very confusing which one is which:
+
+::
+
+  (the debugger)
+  (lldb) run
+  Process 1741640 launched: '<...>/bin/lldb' (aarch64)
+  Process 1741640 stopped and restarted: thread 1 received signal: SIGCHLD
+
+  (the debugee)
+  (lldb) target create "/tmp/test.o"
+  Current executable set to '/tmp/test.o' (aarch64).
+
+Another issue is that when you resume the debugee, it will not print the
+``(lldb)`` prompt because as far as it knows it hasn't changed state. A quick
+way around that is to type something that is clearly not a command and hit
+enter.
+
+::
+
+  (lldb) Process 1742266 stopped and restarted: thread 1 received signal: 
SIGCHLD
+  Process 1742266 stopped
+  * thread #1, name = 'lldb', stop reason = signal SIGSTOP
+  frame #0: 0xed5bfbf0 libc.so.6`__GI___libc_read at read.c:26:10
+  (lldb) c
+  Process 1742266 resuming
+  notacommand
+  error: 'notacommand' is not a valid command.
+  (lldb)
+
+You could just remember whether you are in the debugger or the debugee but
+it's thinking overhead, and for interrupt based events you simply may not be
+able to know.
+
+Here are some better approaches. First, you could use another debugger like GDB
+to debug LLDB. Perhaps an IDE like XCode or Visual Studio Code. Something which

DavidSpickett wrote:

Done.

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


[Lldb-commits] [lldb] [lldb][Docs] Add page about debugging lldb itself (PR #65332)

2023-09-06 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][Docs] Add page about debugging lldb itself (PR #65332)

2023-09-06 Thread David Spickett via lldb-commits


@@ -0,0 +1,254 @@
+Debugging LLDB
+==
+
+This page details various ways to debug LLDB itself and other LLDB tools. If
+you want to know how to use LLDB in general, please refer to
+:doc:`/use/tutorial`.
+
+As LLDB is generally split into 2 tools, ``lldb`` and ``lldb-server``
+(``debugserver`` on Mac OS), the techniques shown here will not always apply to
+both. With some knowledge of them all, you can mix and match as needed.
+
+In this document we refer to the initial ``lldb`` as the debugger and the
+program being debugged as the debugee.
+
+Building For Debugging
+--
+
+To build LLDB with debugging information add the following to your CMake
+configuration:
+
+::
+
+  -DCMAKE_BUILD_TYPE=Debug \
+  -DLLDB_EXPORT_ALL_SYMBOLS=1

DavidSpickett wrote:

It's on by default for Debug but there are ways to debug using release builds, 
so I've noted it in that context.

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


[Lldb-commits] [lldb] [lldb][Docs] Add page about debugging lldb itself (PR #65332)

2023-09-06 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][Docs] Add page about debugging lldb itself (PR #65332)

2023-09-06 Thread David Spickett via lldb-commits

DavidSpickett wrote:

There are some bits missing from this e.g. debugging packet exchanges but I 
will hold that for another PR.

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


[Lldb-commits] [lldb] [clang-tidy][misc-include-cleaner]Avoid to insert same include header multiple times (PR #65431)

2023-09-06 Thread Congcong Cai via lldb-commits

https://github.com/HerrCai0907 updated 
https://github.com/llvm/llvm-project/pull/65431:

>From 2b727285edb91a4a88add118745eabc08da9c6fd Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Wed, 6 Sep 2023 09:55:20 +0800
Subject: [PATCH 1/2] [clang-tidy][misc-include-cleaner]Avoid fixes insert same
 include header multiple times

Fixed: #65285
---
 .../clang-tidy/misc/IncludeCleanerCheck.cpp   | 21 +++-
 clang-tools-extra/docs/ReleaseNotes.rst   |  3 +-
 .../clang-tidy/IncludeCleanerTest.cpp | 32 +++
 3 files changed, 47 insertions(+), 9 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
index 2658c4b38702ca..d8afe451c99bb7 100644
--- a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
@@ -199,6 +199,9 @@ void IncludeCleanerCheck::check(const 
MatchFinder::MatchResult &Result) {
 
   tooling::HeaderIncludes HeaderIncludes(getCurrentMainFile(), Code,
  FileStyle->IncludeStyle);
+  // `tooling::HeaderIncludes::insert` will not modify `ExistingIncludes`. We
+  // should handle repeat include here
+  std::set InsertedHeader{};
   for (const auto &Inc : Missing) {
 std::string Spelling = include_cleaner::spellHeader(
 {Inc.Missing, PP->getHeaderSearchInfo(), MainFile});
@@ -209,14 +212,16 @@ void IncludeCleanerCheck::check(const 
MatchFinder::MatchResult &Result) {
 // main file.
 if (auto Replacement =
 HeaderIncludes.insert(llvm::StringRef{Spelling}.trim("\"<>"),
-  Angled, tooling::IncludeDirective::Include))
-  diag(SM->getSpellingLoc(Inc.SymRef.RefLocation),
-   "no header providing \"%0\" is directly included")
-  << Inc.SymRef.Target.name()
-  << FixItHint::CreateInsertion(
- SM->getComposedLoc(SM->getMainFileID(),
-Replacement->getOffset()),
- Replacement->getReplacementText());
+  Angled, tooling::IncludeDirective::Include)) 
{
+  DiagnosticBuilder DB =
+  diag(SM->getSpellingLoc(Inc.SymRef.RefLocation),
+   "no header providing \"%0\" is directly included")
+  << Inc.SymRef.Target.name();
+  if 
(InsertedHeader.insert(Replacement->getReplacementText().str()).second)
+DB << FixItHint::CreateInsertion(
+SM->getComposedLoc(SM->getMainFileID(), Replacement->getOffset()),
+Replacement->getReplacementText());
+}
   }
 }
 
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 5dfda9928aca20..571a50e75bc9b0 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -224,7 +224,8 @@ Changes in existing checks
 
 - Improved :doc:`misc-include-cleaner
   ` check by adding option
-  `DeduplicateFindings` to output one finding per symbol occurrence.
+  `DeduplicateFindings` to output one finding per symbol occurrence 
+  and avoid fixes insert same include header multiple times.
 
 - Improved :doc:`misc-redundant-expression
   ` check to ignore
diff --git a/clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp 
b/clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp
index fe3e38958f8985..f84133b01a3a49 100644
--- a/clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp
+++ b/clang-tools-extra/unittests/clang-tidy/IncludeCleanerTest.cpp
@@ -184,6 +184,38 @@ int QuxResult = qux();
)"}}));
 }
 
+
+TEST(IncludeCleanerCheckTest, MultipleTimeMissingInclude) {
+  const char *PreCode = R"(
+#include "bar.h"
+
+int BarResult = bar();
+int BazResult_0 = baz_0();
+int BazResult_1 = baz_1();
+)";
+  const char *PostCode = R"(
+#include "bar.h"
+#include "baz.h"
+
+int BarResult = bar();
+int BazResult_0 = baz_0();
+int BazResult_1 = baz_1();
+)";
+
+  std::vector Errors;
+  EXPECT_EQ(PostCode,
+runCheckOnCode(
+PreCode, &Errors, "file.cpp", std::nullopt, ClangTidyOptions(),
+{{"bar.h", R"(#pragma once
+  #include "baz.h"
+  int bar();
+   )"},
+ {"baz.h", R"(#pragma once
+  int baz_0();
+  int baz_1();
+   )"}}));
+}
+
 TEST(IncludeCleanerCheckTest, SystemMissingIncludes) {
   const char *PreCode = R"(
 #include 

>From 403b03e2ced5b70fc10aa003b9f72e269ed61dad Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Wed, 6 Sep 2023 13:38:24 +0800
Subject: [PATCH 2/2] add areDiagsSelfContained check

---
 clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/misc/IncludeCleane

[Lldb-commits] [lldb] e821914 - [LLDB] Skip TestBSDArchives.py on windows

2023-09-06 Thread Muhammad Omair Javaid via lldb-commits

Author: Muhammad Omair Javaid
Date: 2023-09-06T14:03:21+05:00
New Revision: e82191469ec408a39cf13ebe6a7dfb03787f09c1

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

LOG: [LLDB] Skip TestBSDArchives.py on windows

This fixes LLDB windows buildbot after updates to TestBSDArchives.py.
https://lab.llvm.org/buildbot/#/builders/219/builds/5408
I have marked new failing test as an expected failure on Windows.

Added: 


Modified: 
lldb/test/API/functionalities/archives/TestBSDArchives.py

Removed: 




diff  --git a/lldb/test/API/functionalities/archives/TestBSDArchives.py 
b/lldb/test/API/functionalities/archives/TestBSDArchives.py
index cefcb95cb9e0b6..9ec21ba2e821c1 100644
--- a/lldb/test/API/functionalities/archives/TestBSDArchives.py
+++ b/lldb/test/API/functionalities/archives/TestBSDArchives.py
@@ -124,6 +124,10 @@ def test_frame_var_errors_when_archive_missing(self):
 self.check_frame_variable_errors(thread, error_strings)
 
 @skipIfRemote
+@expectedFailureAll(
+oslist=["windows"],
+bugnumber="llvm.org/pr24527.  Makefile.rules doesn't know how to build 
static libs on Windows",
+)
 def test_archive_specifications(self):
 """
 Create archives and make sure the information we get when retrieving



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


[Lldb-commits] [PATCH] D157609: [lldb] Add more ways to find split DWARF files

2023-09-06 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett updated this revision to Diff 556016.
DavidSpickett added a comment.

Log when comp dir not found and carry on to fallback search.

Add a test for the search path being a symlink.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157609

Files:
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  
lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-path-symlink-relative-compdir.c
  
lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-dwoname-absolute-compdir.c
  
lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-absolute-compdir.c
  
lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-relative-compdir.c
  
lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-relative-compdir.c
  lldb/test/Shell/SymbolFile/DWARF/dwo-relative-filename-only-binary-dir.c

Index: lldb/test/Shell/SymbolFile/DWARF/dwo-relative-filename-only-binary-dir.c
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/dwo-relative-filename-only-binary-dir.c
@@ -0,0 +1,21 @@
+/// Check that LLDB can find a relative DWO file next to a binary just using the
+/// filename of that DWO. For example "main.dwo" not "a/b/main.dwo".
+// RUN: rm -rf %t.compdir/
+// RUN: mkdir -p %t.compdir/a/b/
+// RUN: cp %s %t.compdir/a/b/main.c
+// RUN: cd %t.compdir/a/
+/// The produced DWO is named b/main-main.dwo, with a DW_AT_comp_dir of a/.
+// RUN: %clang_host -g -gsplit-dwarf -fdebug-prefix-map=%t.compdir=. b/main.c -o b/main
+// RUN: cd ../..
+/// Move binary and DWO out of expected locations.
+// RUN: mv %t.compdir/a/b/main %t.compdir/
+// RUN: mv %t.compdir/a/b/*.dwo %t.compdir/
+// RUN: %lldb --no-lldbinit %t.compdir/main \
+// RUN:   -o "b main" -o "run" -o "p num" --batch 2>&1 | FileCheck %s
+
+// CHECK-NOT: warning: {{.*}}main unable to locate separate debug file (dwo, dwp). Debugging will be degraded.
+// CHECK: (int) 5
+
+int num = 5;
+
+int main(void) { return 0; }
\ No newline at end of file
Index: lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-relative-compdir.c
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-relative-compdir.c
@@ -0,0 +1,27 @@
+/// Check that LLDB uses the paths in target.debug-file-search-paths to find
+/// split DWARF files with a relative DW_AT_comp_dir set, when the program file
+/// has been moved and/or we're executing it from another directory.
+// RUN: rm -rf %t.compdir/ %t.e/
+// RUN: mkdir -p %t.compdir/a/b/c/d/
+// RUN: cp %s %t.compdir/a/b/c/d/main.c
+// RUN: cd %t.compdir/a/b/
+/// The produced DWO is named c/d/main-main.dwo, with a DW_AT_comp_dir of a/b.
+// RUN: %clang_host -g -gsplit-dwarf -fdebug-prefix-map=%t.compdir=. c/d/main.c -o c/d/main
+// RUN: cd ../../..
+/// Move only the program, leaving the DWO file in place.
+// RUN: mv %t.compdir/a/b/c/d/main %t.compdir/a/
+/// Debug it from yet another path.
+// RUN: mkdir -p %t.e/
+// RUN: cd %t.e
+/// LLDB won't find the DWO next to the binary or in the current dir, so it
+/// should find the DWO file by doing %t.compdir/ + a/b/ + c/d/main-main.dwo.
+// RUN: %lldb --no-lldbinit %t.compdir/a/main \
+// RUN:   -O "settings append target.debug-file-search-paths %t.compdir" \
+// RUN:   -o "b main" -o "run" -o "p num" --batch 2>&1 | FileCheck %s
+
+// CHECK-NOT: warning: {{.*}}main unable to locate separate debug file (dwo, dwp). Debugging will be degraded.
+// CHECK: (int) 5
+
+int num = 5;
+
+int main(void) { return 0; }
Index: lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-relative-compdir.c
===
--- /dev/null
+++ lldb/test/Shell/SymbolFile/DWARF/dwo-debug-file-search-paths-filename-only-relative-compdir.c
@@ -0,0 +1,26 @@
+/// Check that when LLDB is looking for a relative DWO it uses the debug search
+/// paths setting. If it doesn't find it by adding the whole relative path to
+/// of DWO it should try adding just the filename (e.g. main.dwo) to each debug
+/// search path.
+// RUN: rm -rf %t.compdir/
+// RUN: mkdir -p %t.compdir/a/b/
+// RUN: cp %s %t.compdir/a/b/main.c
+// RUN: cd %t.compdir/a/
+/// The produced DWO is named /b/main-main.dwo, with a DW_AT_comp_dir of a/.
+// RUN: %clang_host -g -gsplit-dwarf -fdebug-prefix-map=%t.compdir=. b/main.c -o b/main
+// RUN: cd ../..
+/// Move the DWO file away from the expected location.
+// RUN: mv %t.compdir/a/b/*.dwo %t.compdir/
+/// LLDB won't find the DWO next to the binary or by adding the relative path
+/// to any of the search paths. So it should find the DWO file at
+/// %t.compdir/main-main.dwo.
+// RUN: %lldb --no-lldbinit %t.compdir/a/b/main \
+// RUN:   -O "settings append target.debug-file-search-paths %t.compdir" \
+// RUN:   -o "b main" -o "run" -o "p num" --batch 2

[Lldb-commits] [PATCH] D157609: [lldb] Add more ways to find split DWARF files

2023-09-06 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett marked 2 inline comments as done.
DavidSpickett added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:1747-1754
 if (!comp_dir) {
   unit.SetDwoError(Status::createWithFormat(
   "unable to locate relative .dwo debug file \"{0}\" for "
   "skeleton DIE {1:x16} without valid DW_AT_comp_dir "
   "attribute",
   dwo_name, cu_die.GetOffset()));
   return nullptr;

clayborg wrote:
> If we have no comp_dir, then we should still search for the file right? We 
> are returning early here without trying to use the search paths?
Refactored this to log and carry on to the later searches.

We don't test for this situation at all so it's likely very rare, which means 
logging it is fine. Standard advice on unexplained failures to find things is 
check the logs.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:1779
+FileSystem::Instance().Resolve(dirspec);
+if (!FileSystem::Instance().IsDirectory(dirspec))
+  continue;

clayborg wrote:
> Will this return false for a symlink to a directory?
In this case no because comp_dir was always being added to it, unless the 
result of that was also pointing to a symlink.

I have added a test case to check you can set the search path to a symlink, I'm 
not sure of an easy way to do that for comp_dir.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157609

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


[Lldb-commits] [PATCH] D157609: [lldb] Add more ways to find split DWARF files

2023-09-06 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett marked 2 inline comments as done.
DavidSpickett added inline comments.



Comment at: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp:1779
+FileSystem::Instance().Resolve(dirspec);
+if (!FileSystem::Instance().IsDirectory(dirspec))
+  continue;

DavidSpickett wrote:
> clayborg wrote:
> > Will this return false for a symlink to a directory?
> In this case no because comp_dir was always being added to it, unless the 
> result of that was also pointing to a symlink.
> 
> I have added a test case to check you can set the search path to a symlink, 
> I'm not sure of an easy way to do that for comp_dir.
The underlying filesystem does have different types for a directory and a 
symlink, so the general answer is yes it appears that IsDirectory would return 
false for a symlink.

Which you'd think would affect the later searches using the search path only, 
but it doesn't. So maybe resolving helps there, not sure. End result is good 
anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157609

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


[Lldb-commits] [lldb] Add flags to dump IR to a file before and after LLVM passes (PR #65179)

2023-09-06 Thread Nuri Amari via lldb-commits

https://github.com/NuriAmari updated 
https://github.com/llvm/llvm-project/pull/65179:

>From 5d395c85b84e5a554df4b092014d38123e666c6c Mon Sep 17 00:00:00 2001
From: Nuri Amari 
Date: Tue, 29 Aug 2023 10:10:57 -0700
Subject: [PATCH 1/4] Add flags to dump IR to a file before and after LLVM
 passes

Summary:

LLVM offers -print-after and -print-before flags that allow you
to print IR to stderr before and after any pass you want. This can
be useful for debugging LLVM optimization issue, but is far too
noisy for large builds.

This patch adds analogous options -dump-after and -dump-before that
dump the IR to appropriately named files. In addition, it also
introduces flags -dump-after-all, -dump-before-all and -ir-dump-directory
to control where the files are written to.

Test Plan:

Included LIT tests:
```
ninja check-llvm
```
---
 llvm/include/llvm/IR/PrintPasses.h|  21 +++
 .../llvm/Passes/StandardInstrumentations.h|  57 ++
 llvm/lib/IR/PrintPasses.cpp   |  54 ++
 llvm/lib/Passes/PassBuilder.cpp   |   3 +-
 llvm/lib/Passes/StandardInstrumentations.cpp  | 178 ++
 .../Other/dump-before-after-file-contents |  76 
 llvm/test/Other/dump-before-after-filenames   |  71 +++
 .../Other/dump-before-after-multiple-modules  |  36 
 llvm/test/Other/lit.local.cfg |   1 +
 9 files changed, 496 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/Other/dump-before-after-file-contents
 create mode 100644 llvm/test/Other/dump-before-after-filenames
 create mode 100644 llvm/test/Other/dump-before-after-multiple-modules
 create mode 100644 llvm/test/Other/lit.local.cfg

diff --git a/llvm/include/llvm/IR/PrintPasses.h 
b/llvm/include/llvm/IR/PrintPasses.h
index 95b97e76c867cb..b2a9017521c6a9 100644
--- a/llvm/include/llvm/IR/PrintPasses.h
+++ b/llvm/include/llvm/IR/PrintPasses.h
@@ -48,6 +48,27 @@ bool shouldPrintAfterAll();
 std::vector printBeforePasses();
 std::vector printAfterPasses();
 
+// Returns true if dumping IR to a file before/after some pass is enabled
+// wether all passes or a specific pass.
+bool shouldDumpBeforeSomePass();
+bool shouldDumpAfterSomePass();
+
+// Returns true if we should dump IR to a file before/after a specific pass. 
The
+// argument should be the pass ID, e.g. "instcombine"
+bool shouldDumpBeforePass(StringRef PassID);
+bool shouldDumpAfterPass(StringRef PassID);
+
+// Returns true if we should dump IR to a file before/after all passes.
+bool shouldDumpBeforeAll();
+bool shouldDumpAfterAll();
+
+// The list of passes to dump IR to a file before/after, if we only want
+// to print before/after specific passes.
+std::vector dumpBeforePasses();
+std::vector dumpAfterPasses();
+
+StringRef irInstrumentationDumpDirectory();
+
 // Returns true if we should always print the entire module.
 bool forcePrintModuleIR();
 
diff --git a/llvm/include/llvm/Passes/StandardInstrumentations.h 
b/llvm/include/llvm/Passes/StandardInstrumentations.h
index 331130c6b22d99..4068a68aa956fd 100644
--- a/llvm/include/llvm/Passes/StandardInstrumentations.h
+++ b/llvm/include/llvm/Passes/StandardInstrumentations.h
@@ -69,6 +69,62 @@ class PrintIRInstrumentation {
   unsigned CurrentPassNumber = 0;
 };
 
+class DumpIRInstrumentation {
+public:
+  void registerCallbacks(PassInstrumentationCallbacks &PIC);
+
+private:
+  void dumpBeforePass(StringRef PassID, Any IR);
+  void dumpAfterPass(StringRef PassID, Any IR);
+
+  bool shouldDumpBeforePass(StringRef PassID);
+  bool shouldDumpAfterPass(StringRef PassID);
+
+  PassInstrumentationCallbacks *PIC;
+
+  // The module currently being processed in the pipeline.
+  Module const *CurrentModule = nullptr;
+
+  void pushPass(StringRef PassID, Any IR);
+  void popPass(StringRef PassID);
+
+  SmallString<16> InstrumentationDumpDirectory;
+  StringRef fetchInstrumentationDumpDirectory();
+
+  SmallString<16> fetchCurrentInstrumentationDumpFile(StringRef Suffix);
+
+  // A table to store how many times a given pass has run at the current 
"nested
+  // level"
+  using PassRunsFrequencyTableT = DenseMap;
+  // A stack each frame of which (aside from the very first) represents a pass
+  // being run on some unit of IR. The larger, the stack grows, the smaller the
+  // unit of IR. For example, we would first push a module pass, then for each
+  // function pass in that module pass, we would push a frame and so on. This
+  // information is used to craft the output path for this logging.
+  //
+  // Each frame contains a map to track how many times a given subpass runs. 
For
+  // example, to keep track of how many times a function pass Foo runs within a
+  // module pass Bar. The first frame of the stack represents the module being
+  // processed rather than any particular pass. This is to create a frequency
+  // table to track module level pass run counts without having to special case
+  // that logic.
+  //
+  // When a change in the module being processed is detected, t

[Lldb-commits] [lldb] Add flags to dump IR to a file before and after LLVM passes (PR #65179)

2023-09-06 Thread Nuri Amari via lldb-commits


@@ -0,0 +1,71 @@
+; RUN: mkdir -p %t/logs
+; RUN: rm -rf %t/logs
+
+; Basic dump before and after a single module pass
+; RUN: opt %s -disable-output -passes='no-op-module' -ir-dump-directory 
%t/logs -dump-after=no-op-module -dump-before=no-op-module
+; RUN: find %t/logs -type f -print | FileCheck %s --check-prefix=SINGLE-RUN 
-DSOURCE_FILE_NAME=%s
+; SINGLE-RUN-DAG: [[SOURCE_FILE_NAME]]/0.NoOpModulePass.0-before.ll
+; SINGLE-RUN-DAG: [[SOURCE_FILE_NAME]]/0.NoOpModulePass.0-after.ll
+; RUN: rm -rf %t/logs
+
+; Dump before and after multiple runs of the same module pass
+; RUN: opt %s -disable-output -passes='no-op-module,no-op-module,no-op-module' 
-ir-dump-directory %t/logs -dump-after=no-op-module -dump-before=no-op-module
+; RUN: find %t/logs -type f -print | FileCheck %s --check-prefix=MULTIPLE-RUNS 
-DSOURCE_FILE_NAME=%s
+; MULTIPLE-RUNS-DAG: [[SOURCE_FILE_NAME]]/0.NoOpModulePass.0-before.ll
+; MULTIPLE-RUNS-DAG: [[SOURCE_FILE_NAME]]/0.NoOpModulePass.0-after.ll
+; MULTIPLE-RUNS-DAG: [[SOURCE_FILE_NAME]]/1.NoOpModulePass.1-before.ll
+; MULTIPLE-RUNS-DAG: [[SOURCE_FILE_NAME]]/1.NoOpModulePass.1-after.ll
+; MULTIPLE-RUNS-DAG: [[SOURCE_FILE_NAME]]/2.NoOpModulePass.2-before.ll
+; MULTIPLE-RUNS-DAG: [[SOURCE_FILE_NAME]]/2.NoOpModulePass.2-after.ll
+; RUN: rm -rf %t/logs
+
+; Dump before and after multiple passes, some nested
+; RUN: opt %s -disable-output 
-passes='no-op-module,function(no-op-function),function(loop(no-op-loop)),no-op-module'
 -ir-dump-directory %t/logs -dump-after=no-op-module,no-op-function,no-op-loop 
-dump-before=no-op-module,no-op-function,no-op-loop
+; RUN: find %t/logs -type f -print | FileCheck %s 
--check-prefix=MULTIPLE-NESTED-RUNS -DSOURCE_FILE_NAME=%s
+; MULTIPLE-NESTED-RUNS-DAG: [[SOURCE_FILE_NAME]]/0.NoOpModulePass.0-before.ll
+; MULTIPLE-NESTED-RUNS-DAG: [[SOURCE_FILE_NAME]]/0.NoOpModulePass.0-after.ll
+; MULTIPLE-NESTED-RUNS-DAG: 
[[SOURCE_FILE_NAME]]/1.ModuleToFunctionPassAdaptor.0/0.PassManager.0/0.NoOpFunctionPass.0-before.ll
+; MULTIPLE-NESTED-RUNS-DAG: 
[[SOURCE_FILE_NAME]]/1.ModuleToFunctionPassAdaptor.0/0.PassManager.0/0.NoOpFunctionPass.0-after.ll
+; MULTIPLE-NESTED-RUNS-DAG: 
[[SOURCE_FILE_NAME]]/1.ModuleToFunctionPassAdaptor.0/1.PassManager.1/0.NoOpFunctionPass.0-before.ll
+; MULTIPLE-NESTED-RUNS-DAG: 
[[SOURCE_FILE_NAME]]/1.ModuleToFunctionPassAdaptor.0/1.PassManager.1/0.NoOpFunctionPass.0-after.ll
+; MULTIPLE-NESTED-RUNS-DAG: 
[[SOURCE_FILE_NAME]]/2.ModuleToFunctionPassAdaptor.1/1.PassManager.1/0.FunctionToLoopPassAdaptor.0/1.PassManager, 
llvm::LoopStandardAnalysisResults&, 
llvm::LPMUpdater&>.0/0.NoOpLoopPass.0-before.ll
+; MULTIPLE-NESTED-RUNS-DAG: 
[[SOURCE_FILE_NAME]]/2.ModuleToFunctionPassAdaptor.1/1.PassManager.1/0.FunctionToLoopPassAdaptor.0/1.PassManager, 
llvm::LoopStandardAnalysisResults&, 
llvm::LPMUpdater&>.0/0.NoOpLoopPass.0-after.ll

NuriAmari wrote:

I made an attempt at this, the trouble is the new PM instrumentation 
infrastructure only provides callbacks with the PassID, which is this verbose 
sometimes. The existing Class name to pass name mapping does not contain 
entries for all passes (ex. adaptors and PMs). 

I think more consistent names are doable, but perhaps something for another 
patch.

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


[Lldb-commits] [lldb] [lldb][Docs] Add page about debugging lldb itself (PR #65332)

2023-09-06 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb][Docs] Add page about debugging lldb itself (PR #65332)

2023-09-06 Thread Jonas Devlieghere via lldb-commits

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

Thanks for working on this!

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


[Lldb-commits] [lldb] ad2453a - [lldb][Docs] Add page about debugging lldb itself (#65332)

2023-09-06 Thread via lldb-commits

Author: David Spickett
Date: 2023-09-06T16:22:28+01:00
New Revision: ad2453a2db22cd5aefabb8961a0cf025f8f7eb03

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

LOG: [lldb][Docs] Add page about debugging lldb itself (#65332)

We have docs about how to use lldb on other programs, this tells you how
to use lldb on ldlb and lldb-server.

Lacking any Mac experience I've not included any debugserver information
apart from stating it will be similar but not the same.

I plan for this page to include sections on debugging tests and other
things but this initial commit is purely about the two main binaries
involved.

Added: 
lldb/docs/resources/debugging.rst

Modified: 
lldb/docs/index.rst

Removed: 




diff  --git a/lldb/docs/index.rst b/lldb/docs/index.rst
index e12a4569cfdd2e..ab67531d415401 100644
--- a/lldb/docs/index.rst
+++ b/lldb/docs/index.rst
@@ -148,6 +148,7 @@ interesting areas to contribute to lldb.
resources/contributing
resources/build
resources/test
+   resources/debugging
resources/fuzzing
resources/sbapi
resources/extensions

diff  --git a/lldb/docs/resources/debugging.rst 
b/lldb/docs/resources/debugging.rst
new file mode 100644
index 00..0cd310e079c23f
--- /dev/null
+++ b/lldb/docs/resources/debugging.rst
@@ -0,0 +1,260 @@
+Debugging
+=
+
+This page details various ways to debug LLDB itself and other LLDB tools. If
+you want to know how to use LLDB in general, please refer to
+:doc:`/use/tutorial`.
+
+As LLDB is generally split into 2 tools, ``lldb`` and ``lldb-server``
+(``debugserver`` on Mac OS), the techniques shown here will not always apply to
+both. With some knowledge of them all, you can mix and match as needed.
+
+In this document we refer to the initial ``lldb`` as the "debugger" and the
+program being debugged as the "inferior".
+
+Building For Debugging
+--
+
+To build LLDB with debugging information add the following to your CMake
+configuration:
+
+::
+
+  -DCMAKE_BUILD_TYPE=Debug \
+  -DLLDB_EXPORT_ALL_SYMBOLS=ON
+
+Note that the ``lldb`` you will use to do the debugging does not itself need to
+have debug information.
+
+Then build as you normally would according to :doc:`/resources/build`.
+
+If you are going to debug in a way that doesn't need debug info (printf, 
strace,
+etc.) we recommend adding ``LLVM_ENABLE_ASSERTIONS=ON`` to Release build
+configurations. This will make LLDB fail earlier instead of continuing with
+invalid state (assertions are enabled by default for Debug builds).
+
+Debugging ``lldb``
+--
+
+The simplest scenario is where we want to debug a local execution of ``lldb``
+like this one:
+
+::
+
+  ./bin/lldb test_program
+
+LLDB is like any other program, so you can use the same approach.
+
+::
+
+  ./bin/lldb -- ./bin/lldb /tmp/test.o
+
+That's it. At least, that's the minimum. There's nothing special about LLDB
+being a debugger that means you can't attach another debugger to it like any
+other program.
+
+What can be an issue is that both debuggers have command line interfaces which
+makes it very confusing which one is which:
+
+::
+
+  (the debugger)
+  (lldb) run
+  Process 1741640 launched: '<...>/bin/lldb' (aarch64)
+  Process 1741640 stopped and restarted: thread 1 received signal: SIGCHLD
+
+  (the inferior)
+  (lldb) target create "/tmp/test.o"
+  Current executable set to '/tmp/test.o' (aarch64).
+
+Another issue is that when you resume the inferior, it will not print the
+``(lldb)`` prompt because as far as it knows it hasn't changed state. A quick
+way around that is to type something that is clearly not a command and hit
+enter.
+
+::
+
+  (lldb) Process 1742266 stopped and restarted: thread 1 received signal: 
SIGCHLD
+  Process 1742266 stopped
+  * thread #1, name = 'lldb', stop reason = signal SIGSTOP
+  frame #0: 0xed5bfbf0 libc.so.6`__GI___libc_read at read.c:26:10
+  (lldb) c
+  Process 1742266 resuming
+  notacommand
+  error: 'notacommand' is not a valid command.
+  (lldb)
+
+You could just remember whether you are in the debugger or the inferior but
+it's more for you to remember, and for interrupt based events you simply may 
not
+be able to know.
+
+Here are some better approaches. First, you could use another debugger like GDB
+to debug LLDB. Perhaps an IDE like Xcode or Visual Studio Code. Something which
+runs LLDB under the hood so you don't have to type in commands to the debugger
+yourself.
+
+Or you could change the prompt text for the debugger and/or inferior.
+
+::
+
+  $ ./bin/lldb -o "settings set prompt \"(lldb debugger) \"" -- \
+./bin/lldb -o "settings set prompt \"(lldb inferior) \"" /tmp/test.o
+  <...>
+  (lldb) settings set prompt "(lldb debugger) "
+  (lldb debugger) run
+  <...>
+  (lld

[Lldb-commits] [lldb] [lldb][Docs] Add page about debugging lldb itself (PR #65332)

2023-09-06 Thread David Spickett via lldb-commits

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


[Lldb-commits] [PATCH] D157609: [lldb] Add more ways to find split DWARF files

2023-09-06 Thread Greg Clayton via Phabricator via lldb-commits
clayborg accepted this revision.
clayborg added a comment.
This revision is now accepted and ready to land.

Thanks a lot for acting on all feedback and getting all of the edge cases! LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157609

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


[Lldb-commits] [lldb] a8138c3 - [lldb] Fix inline_sites.test

2023-09-06 Thread Daniel Paoliello via lldb-commits

Author: Daniel Paoliello
Date: 2023-09-06T11:20:39-07:00
New Revision: a8138c3d2f2e5a64137a2aceb3094faf978786b9

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

LOG: [lldb] Fix inline_sites.test

Fixes `lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test` to use the 
correct line number now that 
https://github.com/llvm/llvm-project/commit/f2f36c9b2955d2d742a198416f1178fd80303921
 is causing the inline call site info to be taken into account.

Added: 


Modified: 
lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test

Removed: 




diff  --git a/lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test 
b/lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test
index e8319341084af6e..f1cf5ffdf703739 100644
--- a/lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test
+++ b/lldb/test/Shell/SymbolFile/NativePDB/inline_sites.test
@@ -23,7 +23,7 @@
 # CHECK-NEXT: 0x00014000103d: /tmp/a.cpp:4
 # CHECK-NEXT: 0x00014000103f: /tmp/a.h:20
 # CHECK-NEXT: 0x000140001044: /tmp/a.h:8
-# CHECK-NEXT: 0x000140001046: /tmp/a.cpp:4, is_terminal_entry = TRUE
+# CHECK-NEXT: 0x000140001046: /tmp/a.cpp:3, is_terminal_entry = TRUE
 
 #CHECK: (lldb) b a.h:5
 #CHECK: Breakpoint 1: where = {{.*}}`main + 4 [inlined] Namespace1::foo at 
a.h:5, address = 0x000140001004



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


[Lldb-commits] [lldb] [lldb-vscode] Display a more descriptive summary for containers and pointers (PR #65514)

2023-09-06 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/65514:

We've been displaying types and addresses for containers, but that's not very 
useful information. A better approach is to compose the summary of containers 
with the summary of a few of its children.

Not only that, we can dereference simple pointers and references to get the 
summary of the pointer variable, which is also better than just showing an 
anddress.

And in the rare case where the user wants to inspect the raw address, they can 
always use the debug console for that.


>From e7ed33687a44992889df60eae5af03fb439aacc0 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Wed, 6 Sep 2023 10:38:41 -0400
Subject: [PATCH] [lldb-vscode] Display a more descriptive summary for
 containers and pointers

We've been displaying types and addresses for containers, but that's not very 
useful information. A better approach is to compose the summary of containers 
with the summary of a few of its children.

Not only that, we can dereference simple pointers and references to get the 
summary of the pointer variable, which is also better than just showing an 
anddress.

And in the rare case where the user wants to inspect the raw address, they can 
always use the debug console for that.
---
 .../tools/lldb-vscode/lldbvscode_testcase.py  |   7 +-
 .../evaluate/TestVSCode_evaluate.py   |   4 +-
 .../variables/TestVSCode_variables.py |  13 +-
 lldb/tools/lldb-vscode/JSONUtils.cpp  | 128 --
 4 files changed, 127 insertions(+), 25 deletions(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index a6c370ccd2036d..00534752eb2719 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -1,8 +1,9 @@
-from lldbsuite.test.lldbtest import *
 import os
-import vscode
 import time
 
+import vscode
+from lldbsuite.test.lldbtest import *
+
 
 class VSCodeTestCaseBase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
@@ -267,7 +268,7 @@ def disassemble(self, threadId=None, frameIndex=None):
 
 if memoryReference not in self.vscode.disassembled_instructions:
 self.vscode.request_disassemble(memoryReference=memoryReference)
-
+
 return self.vscode.disassembled_instructions[memoryReference]
 
 def attach(
diff --git a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py 
b/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
index fee685435c1952..85bd23d9abfdef 100644
--- a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
+++ b/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
@@ -55,7 +55,7 @@ def run_test_evaluate_expressions(self, context=None):
 self.assertEvaluate("var2", "21")
 self.assertEvaluate("static_int", "42")
 self.assertEvaluate("non_static_int", "43")
-self.assertEvaluate("struct1", "my_struct @ 0x.*")
+self.assertEvaluate("struct1", "{foo:15}")
 self.assertEvaluate("struct1.foo", "15")
 self.assertEvaluate("struct2->foo", "16")
 
@@ -85,7 +85,7 @@ def run_test_evaluate_expressions(self, context=None):
 self.assertEvaluate(
 "non_static_int", "10"
 )  # different variable with the same name
-self.assertEvaluate("struct1", "my_struct @ 0x.*")
+self.assertEvaluate("struct1", "{foo:15}")
 self.assertEvaluate("struct1.foo", "15")
 self.assertEvaluate("struct2->foo", "16")
 
diff --git a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py 
b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
index 88bf58e9155ad2..6eb8e87190d007 100644
--- a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
+++ b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
@@ -2,12 +2,13 @@
 Test lldb-vscode setBreakpoints request
 """
 
+import os
+
+import lldbvscode_testcase
 import vscode
+from lldbsuite.test import lldbutil
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-import lldbvscode_testcase
-import os
 
 
 def make_buffer_verify_dict(start_idx, count, offset=0):
@@ -218,12 +219,12 @@ def test_scopes_variables_setVariable_evaluate(self):
 },
 "pt": {
 "equals": {"type": "PointType"},
-"startswith": {"result": "PointType @ 0x"},
+"startswith": {"result": "{x:11, y:22}"},
 "hasVariablesReference": True,
 },
 "pt.buffer": {
 "equals": {"type": "int[32]"},
-"startswith": {"result": "int[32] @ 0x"},
+"startswith": {"result": "{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 
...}"},
   

[Lldb-commits] [lldb] [lldb-vscode] Display a more descriptive summary for containers and pointers (PR #65514)

2023-09-06 Thread via lldb-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65514
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-vscode] Display a more descriptive summary for containers and pointers (PR #65514)

2023-09-06 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Display a more descriptive summary for containers and pointers (PR #65514)

2023-09-06 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Display a more descriptive summary for containers and pointers (PR #65514)

2023-09-06 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Display a more descriptive summary for containers and pointers (PR #65514)

2023-09-06 Thread Walter Erquinigo via lldb-commits

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


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

2023-09-06 Thread Alex Langford via Phabricator via lldb-commits
bulbazord added a comment.

This change seems mostly red in that we're removing a lot of things. What are 
the replacements? I also see you're removing the API lock acquisition in a few 
places, where does that now occur?




Comment at: lldb/bindings/python/python-wrapper.swig:266-279
+  switch (arg_info.get().max_positional_args) {
+case 1:
+  // FIXME: Since this is used by different scripting affordances, they 
can have different number
+  // of argument but also different types of arguments (i.e 
SBExecutionContect vs SBProcess)
+  // We need to have a more reliable way to forward positional arguments.
+  result = pfunc(SWIGBridge::ToSWIGWrapper(exe_ctx_sp->GetProcessSP()));
+  break;

Is there no way to check the types of the positional args? This seems like it 
might be a source of future subtle bugs or unexpected behavior.



Comment at: 
lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp:112-114
+//return llvm::createStringError(
+//llvm::inconvertibleErrorCode(),
+//"Failed to create scripted thread interface.");

nit: Remove commented out code.

side note, maybe OperatingSystemPython should have a static factory method so 
we can actually return a meaningful error like this? Since the constructor can 
fail, we might end up with a half-initialized object. Doesn't have to be in 
this change, I think it would make sense for a follow-up.



Comment at: 
lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp:123-128
+//return llvm::createStringError(llvm::inconvertibleErrorCode(),
+//   "Failed to create script object.");
+return;
+  if (!owned_script_object_sp->IsValid())
+//return llvm::createStringError(llvm::inconvertibleErrorCode(),
+//   "Created script object is invalid.");

Same here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159314

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


[Lldb-commits] [lldb] [lldb-vscode] Display a more descriptive summary for containers and pointers (PR #65514)

2023-09-06 Thread River Riddle via lldb-commits


@@ -1,8 +1,9 @@
-from lldbsuite.test.lldbtest import *
 import os
-import vscode
 import time
 
+import vscode

River707 wrote:

Are the changes in this file necessary?

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


[Lldb-commits] [lldb] [lldb-vscode] Display a more descriptive summary for containers and pointers (PR #65514)

2023-09-06 Thread River Riddle via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Display a more descriptive summary for containers and pointers (PR #65514)

2023-09-06 Thread River Riddle via lldb-commits


@@ -132,6 +132,84 @@ std::vector GetStrings(const 
llvm::json::Object *obj,
   return strs;
 }
 
+/// Create a short summary for a container that contains the summary of its
+/// first children, so that the user can get a glimpse of its contents at a
+/// glance.
+static std::optional
+GetSyntheticSummaryForContainer(lldb::SBValue &v) {
+  if (v.TypeIsPointerType() || !v.MightHaveChildren())
+return std::nullopt;
+  /// As this operation can be potentially slow, we limit the total time spent
+  /// fetching children to a few ms.
+  const auto max_evaluation_time = std::chrono::milliseconds(10);
+  /// We don't want to generate a extremely long summary string, so we limit 
its
+  /// length.
+  const size_t max_length = 32;
+
+  auto start = std::chrono::steady_clock::now();
+  std::string summary;
+  llvm::raw_string_ostream os(summary);
+  os << "{";
+
+  llvm::StringRef separator = "";
+
+  for (size_t i = 0, e = v.GetNumChildren(); i < e; ++i) {
+// If we reached the time limit or exceeded the number of characters, we
+// dump `...` to signal that there are more elements in the collection.
+if (summary.size() > max_length ||
+(std::chrono::steady_clock::now() - start) > max_evaluation_time) {
+  os << separator << "...";
+  break;
+}
+lldb::SBValue child = v.GetChildAtIndex(i);
+
+if (llvm::StringRef name = child.GetName(); !name.empty()) {
+  llvm::StringRef value;
+  if (llvm::StringRef summary = child.GetSummary(); !summary.empty())
+value = summary;
+  else
+value = child.GetValue();
+
+  if (!value.empty()) {
+// If the child is an indexed entry, we don't show its index to save
+// characters.
+if (name.starts_with("["))
+  os << separator << value;
+else
+  os << separator << name << ":" << value;
+separator = ", ";
+  }
+}
+  }
+  os << "}";
+
+  if (summary == "{...}" || summary == "{}")
+return std::nullopt;
+  return summary;
+}
+
+/// Return whether we should dereference an SBValue in order to generate a more
+/// meaningful summary string.
+static bool ShouldBeDereferencedForSummary(lldb::SBValue &v) {
+  if (!v.GetType().IsPointerType() && !v.GetType().IsReferenceType())

River707 wrote:

Do we have tests for this `false` cases?

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


[Lldb-commits] [lldb] [lldb-vscode] Display a more descriptive summary for containers and pointers (PR #65514)

2023-09-06 Thread River Riddle via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-vscode] Display a more descriptive summary for containers and pointers (PR #65514)

2023-09-06 Thread Walter Erquinigo via lldb-commits


@@ -132,6 +132,84 @@ std::vector GetStrings(const 
llvm::json::Object *obj,
   return strs;
 }
 
+/// Create a short summary for a container that contains the summary of its
+/// first children, so that the user can get a glimpse of its contents at a
+/// glance.
+static std::optional
+GetSyntheticSummaryForContainer(lldb::SBValue &v) {
+  if (v.TypeIsPointerType() || !v.MightHaveChildren())
+return std::nullopt;
+  /// As this operation can be potentially slow, we limit the total time spent
+  /// fetching children to a few ms.
+  const auto max_evaluation_time = std::chrono::milliseconds(10);
+  /// We don't want to generate a extremely long summary string, so we limit 
its
+  /// length.
+  const size_t max_length = 32;
+
+  auto start = std::chrono::steady_clock::now();
+  std::string summary;
+  llvm::raw_string_ostream os(summary);
+  os << "{";
+
+  llvm::StringRef separator = "";
+
+  for (size_t i = 0, e = v.GetNumChildren(); i < e; ++i) {
+// If we reached the time limit or exceeded the number of characters, we
+// dump `...` to signal that there are more elements in the collection.
+if (summary.size() > max_length ||
+(std::chrono::steady_clock::now() - start) > max_evaluation_time) {
+  os << separator << "...";
+  break;
+}
+lldb::SBValue child = v.GetChildAtIndex(i);
+
+if (llvm::StringRef name = child.GetName(); !name.empty()) {
+  llvm::StringRef value;
+  if (llvm::StringRef summary = child.GetSummary(); !summary.empty())
+value = summary;
+  else
+value = child.GetValue();
+
+  if (!value.empty()) {
+// If the child is an indexed entry, we don't show its index to save
+// characters.
+if (name.starts_with("["))
+  os << separator << value;
+else
+  os << separator << name << ":" << value;
+separator = ", ";
+  }
+}
+  }
+  os << "}";
+
+  if (summary == "{...}" || summary == "{}")
+return std::nullopt;
+  return summary;
+}
+
+/// Return whether we should dereference an SBValue in order to generate a more
+/// meaningful summary string.
+static bool ShouldBeDereferencedForSummary(lldb::SBValue &v) {
+  if (!v.GetType().IsPointerType() && !v.GetType().IsReferenceType())

walter-erquinigo wrote:

Yep, there's a test that includes a char**.

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


[Lldb-commits] [lldb] [lldb-vscode] Display a more descriptive summary for containers and pointers (PR #65514)

2023-09-06 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo updated 
https://github.com/llvm/llvm-project/pull/65514:

>From e7ed33687a44992889df60eae5af03fb439aacc0 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Wed, 6 Sep 2023 10:38:41 -0400
Subject: [PATCH 1/2] [lldb-vscode] Display a more descriptive summary for
 containers and pointers

We've been displaying types and addresses for containers, but that's not very 
useful information. A better approach is to compose the summary of containers 
with the summary of a few of its children.

Not only that, we can dereference simple pointers and references to get the 
summary of the pointer variable, which is also better than just showing an 
anddress.

And in the rare case where the user wants to inspect the raw address, they can 
always use the debug console for that.
---
 .../tools/lldb-vscode/lldbvscode_testcase.py  |   7 +-
 .../evaluate/TestVSCode_evaluate.py   |   4 +-
 .../variables/TestVSCode_variables.py |  13 +-
 lldb/tools/lldb-vscode/JSONUtils.cpp  | 128 --
 4 files changed, 127 insertions(+), 25 deletions(-)

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index a6c370ccd2036de..00534752eb2719d 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -1,8 +1,9 @@
-from lldbsuite.test.lldbtest import *
 import os
-import vscode
 import time
 
+import vscode
+from lldbsuite.test.lldbtest import *
+
 
 class VSCodeTestCaseBase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
@@ -267,7 +268,7 @@ def disassemble(self, threadId=None, frameIndex=None):
 
 if memoryReference not in self.vscode.disassembled_instructions:
 self.vscode.request_disassemble(memoryReference=memoryReference)
-
+
 return self.vscode.disassembled_instructions[memoryReference]
 
 def attach(
diff --git a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py 
b/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
index fee685435c19529..85bd23d9abfdef7 100644
--- a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
+++ b/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
@@ -55,7 +55,7 @@ def run_test_evaluate_expressions(self, context=None):
 self.assertEvaluate("var2", "21")
 self.assertEvaluate("static_int", "42")
 self.assertEvaluate("non_static_int", "43")
-self.assertEvaluate("struct1", "my_struct @ 0x.*")
+self.assertEvaluate("struct1", "{foo:15}")
 self.assertEvaluate("struct1.foo", "15")
 self.assertEvaluate("struct2->foo", "16")
 
@@ -85,7 +85,7 @@ def run_test_evaluate_expressions(self, context=None):
 self.assertEvaluate(
 "non_static_int", "10"
 )  # different variable with the same name
-self.assertEvaluate("struct1", "my_struct @ 0x.*")
+self.assertEvaluate("struct1", "{foo:15}")
 self.assertEvaluate("struct1.foo", "15")
 self.assertEvaluate("struct2->foo", "16")
 
diff --git a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py 
b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
index 88bf58e9155ad2c..6eb8e87190d0074 100644
--- a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
+++ b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
@@ -2,12 +2,13 @@
 Test lldb-vscode setBreakpoints request
 """
 
+import os
+
+import lldbvscode_testcase
 import vscode
+from lldbsuite.test import lldbutil
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-import lldbvscode_testcase
-import os
 
 
 def make_buffer_verify_dict(start_idx, count, offset=0):
@@ -218,12 +219,12 @@ def test_scopes_variables_setVariable_evaluate(self):
 },
 "pt": {
 "equals": {"type": "PointType"},
-"startswith": {"result": "PointType @ 0x"},
+"startswith": {"result": "{x:11, y:22}"},
 "hasVariablesReference": True,
 },
 "pt.buffer": {
 "equals": {"type": "int[32]"},
-"startswith": {"result": "int[32] @ 0x"},
+"startswith": {"result": "{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 
...}"},
 "hasVariablesReference": True,
 },
 "argv": {
@@ -409,7 +410,7 @@ def test_scopes_and_evaluate_expansion(self):
 "name": "pt",
 "response": {
 "equals": {"type": "PointType"},
-"startswith": {"result": "PointType @ 0x"},
+"startswith": {"result": "{x:11, y:22}"},
 "missing": ["indexedVariables"],
 "hasVariablesReference": True,
 },
d

[Lldb-commits] [lldb] [lldb-vscode] Display a more descriptive summary for containers and pointers (PR #65514)

2023-09-06 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] 89a81ec - [lldb-vscode] Display a more descriptive summary for containers and pointers (#65514)

2023-09-06 Thread via lldb-commits

Author: Walter Erquinigo
Date: 2023-09-06T17:13:27-04:00
New Revision: 89a81ec2054919411eb8da1274557cbf97bbfe49

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

LOG: [lldb-vscode] Display a more descriptive summary for containers and 
pointers (#65514)

We've been displaying types and addresses for containers, but that's not
very useful information. A better approach is to compose the summary of
containers with the summary of a few of its children.

Not only that, we can dereference simple pointers and references to get
the summary of the pointer variable, which is also better than just
showing an anddress.

And in the rare case where the user wants to inspect the raw address,
they can always use the debug console for that.

For the record, this is very similar to what the CodeLLDB extension
does, and it seems to give a better experience.

An example of the new output:
https://github.com/llvm/llvm-project/assets/1613874/588659b8-421a-4865-8d67-ce4b6182c4f9";>

And this is the 
https://github.com/llvm/llvm-project/assets/1613874/5768a52e-a773-449d-9aab-1b2fb2a98035";>
old output:

Added: 


Modified: 
lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
lldb/tools/lldb-vscode/JSONUtils.cpp

Removed: 




diff  --git a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py 
b/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
index fee685435c19529..85bd23d9abfdef7 100644
--- a/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
+++ b/lldb/test/API/tools/lldb-vscode/evaluate/TestVSCode_evaluate.py
@@ -55,7 +55,7 @@ def run_test_evaluate_expressions(self, context=None):
 self.assertEvaluate("var2", "21")
 self.assertEvaluate("static_int", "42")
 self.assertEvaluate("non_static_int", "43")
-self.assertEvaluate("struct1", "my_struct @ 0x.*")
+self.assertEvaluate("struct1", "{foo:15}")
 self.assertEvaluate("struct1.foo", "15")
 self.assertEvaluate("struct2->foo", "16")
 
@@ -85,7 +85,7 @@ def run_test_evaluate_expressions(self, context=None):
 self.assertEvaluate(
 "non_static_int", "10"
 )  # 
diff erent variable with the same name
-self.assertEvaluate("struct1", "my_struct @ 0x.*")
+self.assertEvaluate("struct1", "{foo:15}")
 self.assertEvaluate("struct1.foo", "15")
 self.assertEvaluate("struct2->foo", "16")
 

diff  --git a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py 
b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
index 88bf58e9155ad2c..6eb8e87190d0074 100644
--- a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
+++ b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
@@ -2,12 +2,13 @@
 Test lldb-vscode setBreakpoints request
 """
 
+import os
+
+import lldbvscode_testcase
 import vscode
+from lldbsuite.test import lldbutil
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-import lldbvscode_testcase
-import os
 
 
 def make_buffer_verify_dict(start_idx, count, offset=0):
@@ -218,12 +219,12 @@ def test_scopes_variables_setVariable_evaluate(self):
 },
 "pt": {
 "equals": {"type": "PointType"},
-"startswith": {"result": "PointType @ 0x"},
+"startswith": {"result": "{x:11, y:22}"},
 "hasVariablesReference": True,
 },
 "pt.buffer": {
 "equals": {"type": "int[32]"},
-"startswith": {"result": "int[32] @ 0x"},
+"startswith": {"result": "{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 
...}"},
 "hasVariablesReference": True,
 },
 "argv": {
@@ -409,7 +410,7 @@ def test_scopes_and_evaluate_expansion(self):
 "name": "pt",
 "response": {
 "equals": {"type": "PointType"},
-"startswith": {"result": "PointType @ 0x"},
+"startswith": {"result": "{x:11, y:22}"},
 "missing": ["indexedVariables"],
 "hasVariablesReference": True,
 },

diff  --git a/lldb/tools/lldb-vscode/JSONUtils.cpp 
b/lldb/tools/lldb-vscode/JSONUtils.cpp
index e307bb05bc65a77..8cfe6dfeb667d85 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.cpp
+++ b/lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -132,6 +132,84 @@ std::vector GetStrings(const 
llvm::json::Object *obj,
   return strs;
 }
 
+/// Create a short summary for a container that contains the summary of its
+/// first children, so that the user can get a glimpse of its contents at a
+/// glance.
+static std::optiona

[Lldb-commits] [lldb] [RISCV] Added definition of Ventana veyron-v1 processor. (PR #65535)

2023-09-06 Thread via lldb-commits

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


[Lldb-commits] [lldb] [RISCV] Added definition of Ventana veyron-v1 processor. (PR #65535)

2023-09-06 Thread via lldb-commits

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


[Lldb-commits] [lldb] [RISCV] Added definition of Ventana veyron-v1 processor. (PR #65535)

2023-09-06 Thread via lldb-commits

https://github.com/mgudim created 
https://github.com/llvm/llvm-project/pull/65535:

None

>From 6529eb1ad2a4d5922c8a66d3a11514b5c406eac0 Mon Sep 17 00:00:00 2001
From: Mikhail Gudim 
Date: Wed, 6 Sep 2023 17:15:56 -0400
Subject: [PATCH] [RISCV] Added definition of Ventana veyron-v1 processor.

---
 clang/test/Driver/riscv-cpus.c| 25 +++
 clang/test/Misc/target-invalid-cpu-note.c |  2 +-
 llvm/lib/Target/RISCV/RISCVProcessors.td  | 22 
 3 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index bd8488d81c0b156..3eaceedce685fc6 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -37,6 +37,31 @@
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=syntacore-scr1-max | 
FileCheck -check-prefix=MTUNE-SYNTACORE-SCR1-MAX %s
 // MTUNE-SYNTACORE-SCR1-MAX: "-tune-cpu" "syntacore-scr1-max"
 
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=veyron-v1 | FileCheck 
-check-prefix=MCPU-VEYRON-V1 %s
+// MCPU-VEYRON-V1: "-target-cpu" "veyron-v1"
+// MCPU-VEYRON-V1: "-target-feature" "+m"
+// MCPU-VEYRON-V1: "-target-feature" "+a"
+// MCPU-VEYRON-V1: "-target-feature" "+f"
+// MCPU-VEYRON-V1: "-target-feature" "+d"
+// MCPU-VEYRON-V1: "-target-feature" "+c"
+// MCPU-VEYRON-V1: "-target-feature" "+zicbom"
+// MCPU-VEYRON-V1: "-target-feature" "+zicbop"
+// MCPU-VEYRON-V1: "-target-feature" "+zicboz"
+// MCPU-VEYRON-V1: "-target-feature" "+zicntr"
+// MCPU-VEYRON-V1: "-target-feature" "+zicsr"
+// MCPU-VEYRON-V1: "-target-feature" "+zifencei"
+// MCPU-VEYRON-V1: "-target-feature" "+zihintpause"
+// MCPU-VEYRON-V1: "-target-feature" "+zihpm"
+// MCPU-VEYRON-V1: "-target-feature" "+zba"
+// MCPU-VEYRON-V1: "-target-feature" "+zbb"
+// MCPU-VEYRON-V1: "-target-feature" "+zbc"
+// MCPU-VEYRON-V1: "-target-feature" "+zbs"
+// MCPU-VEYRON-V1: "-target-feature" "+xventanacondops"
+// MCPU-VEYRON-V1: "-target-abi" "lp64d"
+
+// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=veyron-v1 | FileCheck 
-check-prefix=MTUNE-VEYRON-V1 %s
+// MTUNE-VEYRON-V1: "-tune-cpu" "veyron-v1"
+
 // Check mtune alias CPU has resolved to the right CPU according XLEN.
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=generic | FileCheck 
-check-prefix=MTUNE-GENERIC-32 %s
 // MTUNE-GENERIC-32: "-tune-cpu" "generic"
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index c44bd6087af4132..6bcbdefb9bb774e 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -93,4 +93,4 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
 // TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
-// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, 
sifive-u74, sifive-x280, generic, rocket, sifive-7-series{{$}}
+// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, 
sifive-u74, sifive-x280, generic, rocket, sifive-7-series{{$}}, veyron-v1
diff --git a/llvm/lib/Target/RISCV/RISCVProcessors.td 
b/llvm/lib/Target/RISCV/RISCVProcessors.td
index 01291001cd7ca24..402ec20fe39ab1c 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -201,3 +201,25 @@ def SYNTACORE_SCR1_MAX : 
RISCVProcessorModel<"syntacore-scr1-max",
   FeatureStdExtM,
   FeatureStdExtC],
  [TuneNoDefaultUnroll]>;
+
+def VENTANA_VEYRON_V1 : RISCVProcessorModel<"veyron-v1",
+NoSchedModel,
+[Feature64Bit,
+ FeatureStdExtZifencei,
+ FeatureStdExtZicsr,
+ FeatureStdExtZicntr,
+ FeatureStdExtZihpm,
+ FeatureStdExtZihintpause,
+ FeatureStdExtM,
+ FeatureStdExtA,
+ FeatureStdExtF,
+ FeatureStdExtD,
+ FeatureStdExtC,
+ FeatureStdExtZba,
+ FeatureStdExtZbb,
+ FeatureStdExtZbc,
+ FeatureStdExtZbs,
+ FeatureStdExtZicbom,
+ FeatureStdExtZicbop,

[Lldb-commits] [lldb] [RISCV] Added definition of Ventana veyron-v1 processor. (PR #65535)

2023-09-06 Thread via lldb-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65535
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [RISCV] Added definition of Ventana veyron-v1 processor. (PR #65535)

2023-09-06 Thread via lldb-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65535
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [RISCV] Added definition of Ventana veyron-v1 processor. (PR #65535)

2023-09-06 Thread via lldb-commits

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


[Lldb-commits] [lldb] [RISCV] Added definition of Ventana veyron-v1 processor. (PR #65535)

2023-09-06 Thread via lldb-commits

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


[Lldb-commits] [lldb] [RISCV] Added definition of Ventana veyron-v1 processor. (PR #65535)

2023-09-06 Thread Michael Maitland via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Fix a GetChildAtIndex call (PR #65537)

2023-09-06 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/65537:

We were invoking GetChildAtIndex(0) without checking the number of children.
This was not crashing but was showing some warnings in python formatters.


>From 78d2b81b4a6fb55b98b42f6e3edd0f6d96f20fd8 Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Wed, 6 Sep 2023 17:40:28 -0400
Subject: [PATCH] [lldb-vscode] Fix a GetChildAtIndex call

We were invoking GetChildAtIndex(0) without checking the number of children.
This was not crashing but was showing some warnings in python formatters.
---
 lldb/tools/lldb-vscode/JSONUtils.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/tools/lldb-vscode/JSONUtils.cpp 
b/lldb/tools/lldb-vscode/JSONUtils.cpp
index 8cfe6dfeb667d85..9a6fd26d2bd5864 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.cpp
+++ b/lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -1133,7 +1133,7 @@ llvm::json::Value CreateVariable(lldb::SBValue v, int64_t 
variablesReference,
 const auto num_children = v.GetNumChildren();
 if (is_array) {
   object.try_emplace("indexedVariables", num_children);
-} else {
+} else if (num_children > 0) {
   // If a type has a synthetic child provider, then the SBType of "v" won't
   // tell us anything about what might be displayed. So we can check if the
   // first child's name is "[0]" and then we can say it is indexed.

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


[Lldb-commits] [lldb] [lldb-vscode] Fix a GetChildAtIndex call (PR #65537)

2023-09-06 Thread via lldb-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65537
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 01c0a6a - [lldb-vscode] Fix a GetChildAtIndex call (#65537)

2023-09-06 Thread via lldb-commits

Author: Walter Erquinigo
Date: 2023-09-06T17:49:12-04:00
New Revision: 01c0a6a0a4c7f9101a35d2ab056191ecff117db5

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

LOG: [lldb-vscode] Fix a GetChildAtIndex call (#65537)

We were invoking GetChildAtIndex(0) without checking the number of
children.
This was not crashing but was showing some warnings in python
formatters.

Added: 


Modified: 
lldb/tools/lldb-vscode/JSONUtils.cpp

Removed: 




diff  --git a/lldb/tools/lldb-vscode/JSONUtils.cpp 
b/lldb/tools/lldb-vscode/JSONUtils.cpp
index 8cfe6dfeb667d8..9a6fd26d2bd586 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.cpp
+++ b/lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -1133,7 +1133,7 @@ llvm::json::Value CreateVariable(lldb::SBValue v, int64_t 
variablesReference,
 const auto num_children = v.GetNumChildren();
 if (is_array) {
   object.try_emplace("indexedVariables", num_children);
-} else {
+} else if (num_children > 0) {
   // If a type has a synthetic child provider, then the SBType of "v" won't
   // tell us anything about what might be displayed. So we can check if the
   // first child's name is "[0]" and then we can say it is indexed.



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


[Lldb-commits] [lldb] [lldb-vscode] Fix a GetChildAtIndex call (PR #65537)

2023-09-06 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [RISCV] Added definition of Ventana veyron-v1 processor. (PR #65535)

2023-09-06 Thread Michael Maitland via lldb-commits


@@ -93,4 +93,4 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
 // TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
-// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, 
sifive-u74, sifive-x280, generic, rocket, sifive-7-series{{$}}
+// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, 
sifive-u74, sifive-x280, generic, rocket, sifive-7-series{{$}}, veyron-v1

michaelmaitland wrote:

I think this should go before the end of line marker?

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


[Lldb-commits] [lldb] Add flags to dump IR to a file before and after LLVM passes (PR #65179)

2023-09-06 Thread Nuri Amari via lldb-commits

NuriAmari wrote:

I've tried this on a real application, and the output paths quickly get 
extremely long. So long that we fail to create the directory structure. Perhaps 
the nesting idea isn't the right choice after all.

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

https://github.com/silee2 created 
https://github.com/llvm/llvm-project/pull/65539:

None

>From 863a72b4e099f4aa24e43fdaaeb2ab0e171a0381 Mon Sep 17 00:00:00 2001
From: "Lee, Sang Ik" 
Date: Wed, 30 Aug 2023 13:44:02 -0700
Subject: [PATCH 01/13] Add SyclRuntimeWrappers and Add CMake option
 MLIR_ENABLE_SYCL_RUNNER

---
 mlir/CMakeLists.txt   |   1 +
 mlir/cmake/modules/FindLevelZero.cmake| 221 ++
 mlir/cmake/modules/FindSyclRuntime.cmake  |  68 +++
 mlir/lib/ExecutionEngine/CMakeLists.txt   |  35 ++
 .../ExecutionEngine/SyclRuntimeWrappers.cpp   | 386 ++
 5 files changed, 711 insertions(+)
 create mode 100644 mlir/cmake/modules/FindLevelZero.cmake
 create mode 100644 mlir/cmake/modules/FindSyclRuntime.cmake
 create mode 100644 mlir/lib/ExecutionEngine/SyclRuntimeWrappers.cpp

diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index fa4f6e76f985fb5..4a67e018273819f 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -116,6 +116,7 @@ 
add_definitions(-DMLIR_ROCM_CONVERSIONS_ENABLED=${MLIR_ENABLE_ROCM_CONVERSIONS})
 
 set(MLIR_ENABLE_CUDA_RUNNER 0 CACHE BOOL "Enable building the mlir CUDA 
runner")
 set(MLIR_ENABLE_ROCM_RUNNER 0 CACHE BOOL "Enable building the mlir ROCm 
runner")
+set(MLIR_ENABLE_SYCL_RUNNER 0 CACHE BOOL "Enable building the mlir Sycl 
runner")
 set(MLIR_ENABLE_SPIRV_CPU_RUNNER 0 CACHE BOOL "Enable building the mlir SPIR-V 
cpu runner")
 set(MLIR_ENABLE_VULKAN_RUNNER 0 CACHE BOOL "Enable building the mlir Vulkan 
runner")
 set(MLIR_ENABLE_NVPTXCOMPILER 0 CACHE BOOL
diff --git a/mlir/cmake/modules/FindLevelZero.cmake 
b/mlir/cmake/modules/FindLevelZero.cmake
new file mode 100644
index 000..012187f0afc0b07
--- /dev/null
+++ b/mlir/cmake/modules/FindLevelZero.cmake
@@ -0,0 +1,221 @@
+# CMake find_package() module for level-zero
+#
+# Example usage:
+#
+# find_package(LevelZero)
+#
+# If successful, the following variables will be defined:
+# LevelZero_FOUND
+# LevelZero_INCLUDE_DIRS
+# LevelZero_LIBRARY
+# LevelZero_LIBRARIES_DIR
+#
+# By default, the module searches the standard paths to locate the "ze_api.h"
+# and the ze_loader shared library. When using a custom level-zero 
installation,
+# the environment variable "LEVEL_ZERO_DIR" should be specified telling the
+# module to get the level-zero library and headers from that location.
+
+include(FindPackageHandleStandardArgs)
+
+# Search path priority
+# 1. CMake Variable LEVEL_ZERO_DIR
+# 2. Environment Variable LEVEL_ZERO_DIR
+
+if(NOT LEVEL_ZERO_DIR)
+if(DEFINED ENV{LEVEL_ZERO_DIR})
+set(LEVEL_ZERO_DIR "$ENV{LEVEL_ZERO_DIR}")
+endif()
+endif()
+
+if(LEVEL_ZERO_DIR)
+find_path(LevelZero_INCLUDE_DIR
+NAMES level_zero/ze_api.h
+PATHS ${LEVEL_ZERO_DIR}/include
+NO_DEFAULT_PATH
+)
+
+if(LINUX)
+find_library(LevelZero_LIBRARY
+NAMES ze_loader
+PATHS ${LEVEL_ZERO_DIR}/lib
+  ${LEVEL_ZERO_DIR}/lib/x86_64-linux-gnu
+NO_DEFAULT_PATH
+)
+else()
+find_library(LevelZero_LIBRARY
+NAMES ze_loader
+PATHS ${LEVEL_ZERO_DIR}/lib
+NO_DEFAULT_PATH
+)
+endif()
+else()
+find_path(LevelZero_INCLUDE_DIR
+NAMES level_zero/ze_api.h
+)
+
+find_library(LevelZero_LIBRARY
+NAMES ze_loader
+)
+endif()
+
+# Compares the two version string that are supposed to be in x.y.z format
+# and reports if the argument VERSION_STR1 is greater than or equal than
+# version_str2. The strings are compared lexicographically after conversion to
+# lists of equal lengths, with the shorter string getting zero-padded.
+function(compare_versions VERSION_STR1 VERSION_STR2 OUTPUT)
+# Convert the strings to list
+string(REPLACE  "." ";" VL1 ${VERSION_STR1})
+string(REPLACE  "." ";" VL2 ${VERSION_STR2})
+# get lengths of both lists
+list(LENGTH VL1 VL1_LEN)
+list(LENGTH VL2 VL2_LEN)
+set(LEN ${VL1_LEN})
+# If they differ in size pad the shorter list with 0s
+if(VL1_LEN GREATER VL2_LEN)
+math(EXPR DIFF "${VL1_LEN} - ${VL2_LEN}" OUTPUT_FORMAT DECIMAL)
+foreach(IDX RANGE 1 ${DIFF} 1)
+list(APPEND VL2 "0")
+endforeach()
+elseif(VL2_LEN GREATER VL2_LEN)
+math(EXPR DIFF "${VL1_LEN} - ${VL2_LEN}" OUTPUT_FORMAT DECIMAL)
+foreach(IDX RANGE 1 ${DIFF} 1)
+list(APPEND VL2 "0")
+endforeach()
+set(LEN ${VL2_LEN})
+endif()
+math(EXPR LEN_SUB_ONE "${LEN}-1")
+foreach(IDX RANGE 0 ${LEN_SUB_ONE} 1)
+list(GET VL1 ${IDX} VAL1)
+list(GET VL2 ${IDX} VAL2)
+
+if(${VAL1} GREATER ${VAL2})
+set(${OUTPUT} TRUE PARENT_SCOPE)
+break()
+elseif(${VAL1} LESS ${VAL2})
+set(${OUTPUT} FALSE PARENT_SCOPE)
+break()
+else()
+set(${OUTPUT} TRUE PARENT_SCOPE)
+endif()
+endforeach()
+
+endfuncti

[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread via lldb-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread via lldb-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread via lldb-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65539
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Jianhui Li via lldb-commits

Jianhui-Li wrote:

@rengolin  @joker-eph  @Hardcode84  

FYI that this PR enables the current GPU dialect on Intel GPU as is, without 
introducing stream/queue to the current GPU dialect. 

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Ivan Butygin via lldb-commits

Hardcode84 wrote:

I suggest to extract `mgpu` interface changes and `serializetoSpirv` pass to 2 
separate PRs.

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

silee2 wrote:

> I suggest to extract `mgpu` interface changes and `serializetoSpirv` pass to 
> 2 separate PRs.

Agree. And the changes are originally from different authors so should be 
splitted.

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via lldb-commits

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via lldb-commits


@@ -0,0 +1,70 @@
+//===- SerializeToSPIRV.cpp - Convert GPU kernel to SPIRV blob 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// This pass iterates all the SPIR-V modules in the top module and serializes
+/// each SPIR-V module to SPIR-V binary and then attachs the binary blob as a
+/// string attribute to the corresponding gpu module.
+///
+//===--===//
+
+#include "mlir/Dialect/GPU/Transforms/Passes.h"
+
+#include "mlir/Dialect/GPU/IR/GPUDialect.h"
+#include "mlir/Dialect/GPU/Transforms/Passes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Target/SPIRV/Serialization.h"
+
+namespace mlir {
+#define GEN_PASS_DEF_GPUSERIALIZETOSPIRVPASS
+#include "mlir/Dialect/GPU/Transforms/Passes.h.inc"
+} // namespace mlir
+
+using namespace mlir;
+
+struct GpuSerializeToSPIRVPass : public 
mlir::impl::GpuSerializeToSPIRVPassBase {
+public:
+  void runOnOperation() override {
+auto mod = getOperation();
+llvm::SmallVector spvBinary;
+for (mlir::gpu::GPUModuleOp gpuMod : mod.getOps()) {
+  auto name = gpuMod.getName();
+  // check that the spv module has the same name with gpu module except the
+  // prefix "__spv__"
+  auto isSameMod = [&](spirv::ModuleOp spvMod) -> bool {
+auto spvModName = spvMod.getName();
+return spvModName->consume_front("__spv__") && spvModName == name;
+  };
+  auto spvMods = mod.getOps();
+  auto it = llvm::find_if(spvMods, isSameMod);

joker-eph wrote:

This is really costly, can you build a symbol table once at the beginning of 
the function and use it for the queries instead?

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via lldb-commits


@@ -0,0 +1,70 @@
+//===- SerializeToSPIRV.cpp - Convert GPU kernel to SPIRV blob 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// This pass iterates all the SPIR-V modules in the top module and serializes
+/// each SPIR-V module to SPIR-V binary and then attachs the binary blob as a
+/// string attribute to the corresponding gpu module.
+///
+//===--===//
+
+#include "mlir/Dialect/GPU/Transforms/Passes.h"
+
+#include "mlir/Dialect/GPU/IR/GPUDialect.h"
+#include "mlir/Dialect/GPU/Transforms/Passes.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+#include "mlir/Target/SPIRV/Serialization.h"
+
+namespace mlir {
+#define GEN_PASS_DEF_GPUSERIALIZETOSPIRVPASS
+#include "mlir/Dialect/GPU/Transforms/Passes.h.inc"
+} // namespace mlir
+
+using namespace mlir;
+
+struct GpuSerializeToSPIRVPass : public 
mlir::impl::GpuSerializeToSPIRVPassBase {
+public:
+  void runOnOperation() override {
+auto mod = getOperation();
+llvm::SmallVector spvBinary;
+for (mlir::gpu::GPUModuleOp gpuMod : mod.getOps()) {
+  auto name = gpuMod.getName();
+  // check that the spv module has the same name with gpu module except the
+  // prefix "__spv__"
+  auto isSameMod = [&](spirv::ModuleOp spvMod) -> bool {
+auto spvModName = spvMod.getName();
+return spvModName->consume_front("__spv__") && spvModName == name;
+  };
+  auto spvMods = mod.getOps();
+  auto it = llvm::find_if(spvMods, isSameMod);
+  if (it == spvMods.end()) {
+gpuMod.emitError() << "Unable to find corresponding SPIR-V module";
+signalPassFailure();
+return;
+  }
+  auto spvMod = *it;
+
+  spvBinary.clear();
+  // serialize the spv module to spv binary
+  if (mlir::failed(spirv::serialize(spvMod, spvBinary))) {
+spvMod.emitError() << "Failed to serialize SPIR-V module";
+signalPassFailure();
+return;
+  }
+
+  // attach the spv binary to the gpu module
+  auto spvData =
+  llvm::StringRef(reinterpret_cast(spvBinary.data()),
+  spvBinary.size() * sizeof(uint32_t));
+  auto spvAttr = mlir::StringAttr::get(&getContext(), spvData);
+  gpuMod->setAttr(gpu::getDefaultGpuBinaryAnnotation(), spvAttr);
+  spvMod->erase();
+}
+  }
+};

joker-eph wrote:

@fabianmcg : how would that fit in the new serialization flow?

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via lldb-commits


@@ -811,8 +812,13 @@ LogicalResult 
ConvertAllocOpToGpuRuntimeCallPattern::matchAndRewrite(
   // descriptor.
   Type elementPtrType = this->getElementPtrType(memRefType);
   auto stream = adaptor.getAsyncDependencies().front();
+
+  auto isHostShared = rewriter.create(
+  loc, llvmInt64Type, rewriter.getI64IntegerAttr(isShared));
+
   Value allocatedPtr =
-  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream}).getResult();
+  allocCallBuilder.create(loc, rewriter, {sizeBytes, stream, isHostShared})
+  .getResult();

joker-eph wrote:

I see a unit-test for this: but can you send everything related to 
`isHostShared` in a separate PR?


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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph commented:

LGTM overall, this should likely get reviewed by @antiagainst / @kuhar ; and 
it's be great if you can split the independent changes and send them ahead of 
the e2e integration.

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


[Lldb-commits] [lldb] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Mehdi Amini via lldb-commits


@@ -71,7 +71,8 @@ void GPUToSPIRVPass::runOnOperation() {
   std::unique_ptr target =
   spirv::getMemorySpaceToStorageClassTarget(*context);
   spirv::MemorySpaceToStorageClassMap memorySpaceMap =
-  spirv::mapMemorySpaceToVulkanStorageClass;
+  this->useOpenCL ? spirv::mapMemorySpaceToOpenCLStorageClass :
+  spirv::mapMemorySpaceToVulkanStorageClass;

joker-eph wrote:

Can you point out which unit-test is covering this? Can you send this in a 
separate PR?

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


[Lldb-commits] [lldb] [lldb-vscode] Show a fake child with the raw value of synthetic types (PR #65552)

2023-09-06 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo created 
https://github.com/llvm/llvm-project/pull/65552:

Currently, if the user wants to inspect the raw version of a synthetic 
variable, they have to go to the debug console and type `frame var , 
which is not a great experience. Taking inspiration from CodeLLDB, this adds a 
`[raw]` child to every synthetic variable so that this kind of inspection can 
be done visually.


>From 5a5f3031e381ef3b2bf5bf76923548c56bc17b2b Mon Sep 17 00:00:00 2001
From: walter erquinigo 
Date: Wed, 6 Sep 2023 20:01:37 -0400
Subject: [PATCH] [lldb-vscode] Show a fake child with the raw value of
 synthetic types

Currently, if the user wants to inspect the raw version of a synthetic 
variable, they have to go to the debug console and type `frame var , 
which is not a great experience. Taking inspiration from CodeLLDB, this adds a 
`[raw]` child to every synthetic variable so that this kind of inspection can 
be done visually.
---
 .../variables/TestVSCode_variables.py | 14 
 lldb/tools/lldb-vscode/JSONUtils.cpp  | 17 +++---
 lldb/tools/lldb-vscode/JSONUtils.h|  7 +++-
 lldb/tools/lldb-vscode/lldb-vscode.cpp| 33 +--
 4 files changed, 55 insertions(+), 16 deletions(-)

diff --git a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py 
b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
index 6eb8e87190d0074..953f330e14a0f97 100644
--- a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
+++ b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
@@ -517,6 +517,20 @@ def test_indexedVariables(self):
 }
 self.verify_variables(verify_locals, locals)
 
+# We also verify that we produce a "[raw]" fake child with the real
+# SBValue for the synthetic type.
+verify_children = {
+"[0]": {"equals": {"type": "int", "value": "0"}},
+"[1]": {"equals": {"type": "int", "value": "0"}},
+"[2]": {"equals": {"type": "int", "value": "0"}},
+"[3]": {"equals": {"type": "int", "value": "0"}},
+"[4]": {"equals": {"type": "int", "value": "0"}},
+"[raw]": {"contains": {"type": ["vector"]}},
+}
+children = 
self.vscode.request_variables(locals[2]["variablesReference"])["body"]["variables"]
+self.verify_variables(verify_children, children)
+
+
 @skipIfWindows
 @skipIfRemote
 def test_registers(self):
diff --git a/lldb/tools/lldb-vscode/JSONUtils.cpp 
b/lldb/tools/lldb-vscode/JSONUtils.cpp
index 9a6fd26d2bd5864..e34448c9b7f2f85 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.cpp
+++ b/lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -1103,10 +1103,13 @@ std::string 
CreateUniqueVariableNameForDisplay(lldb::SBValue v,
 // }
 llvm::json::Value CreateVariable(lldb::SBValue v, int64_t variablesReference,
  int64_t varID, bool format_hex,
- bool is_name_duplicated) {
+ bool is_name_duplicated,
+ std::optional custom_name) {
   llvm::json::Object object;
-  EmplaceSafeString(object, "name",
-CreateUniqueVariableNameForDisplay(v, is_name_duplicated));
+  EmplaceSafeString(
+  object, "name",
+  custom_name ? *custom_name
+  : CreateUniqueVariableNameForDisplay(v, is_name_duplicated));
 
   if (format_hex)
 v.SetFormat(lldb::eFormatHex);
@@ -1131,15 +1134,19 @@ llvm::json::Value CreateVariable(lldb::SBValue v, 
int64_t variablesReference,
   const bool is_synthetic = v.IsSynthetic();
   if (is_array || is_synthetic) {
 const auto num_children = v.GetNumChildren();
+// We create a "[raw]" fake child for each synthetic type, so we have to
+// account for it when returning indexed variables. We don't need to do 
this
+// for non-indexed ones.
+int actual_num_children = num_children + (is_synthetic ? 1 : 0);
 if (is_array) {
-  object.try_emplace("indexedVariables", num_children);
+  object.try_emplace("indexedVariables", actual_num_children);
 } else if (num_children > 0) {
   // If a type has a synthetic child provider, then the SBType of "v" won't
   // tell us anything about what might be displayed. So we can check if the
   // first child's name is "[0]" and then we can say it is indexed.
   const char *first_child_name = v.GetChildAtIndex(0).GetName();
   if (first_child_name && strcmp(first_child_name, "[0]") == 0)
-object.try_emplace("indexedVariables", num_children);
+object.try_emplace("indexedVariables", actual_num_children);
 }
   }
   EmplaceSafeString(object, "type", type_cstr ? type_cstr : NO_TYPENAME);
diff --git a/lldb/tools/lldb-vscode/JSONUtils.h 
b/lldb/tools/lldb-vscode/JSONUtils.h
index 516bc462eae1b16..2013147f5d3532a 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.h
+++ b/lldb/tools/lldb-vscode/JSONUtils.h
@@

[Lldb-commits] [lldb] [lldb-vscode] Show a fake child with the raw value of synthetic types (PR #65552)

2023-09-06 Thread via lldb-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/65552
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-vscode] Show a fake child with the raw value of synthetic types (PR #65552)

2023-09-06 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Show a fake child with the raw value of synthetic types (PR #65552)

2023-09-06 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Show a fake child with the raw value of synthetic types (PR #65552)

2023-09-06 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Johannes Doerfert via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Show a fake child with the raw value of synthetic types (PR #65552)

2023-09-06 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] [lldb-vscode] Show a fake child with the raw value of synthetic types (PR #65552)

2023-09-06 Thread River Riddle via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-vscode] Show a fake child with the raw value of synthetic types (PR #65552)

2023-09-06 Thread Walter Erquinigo via lldb-commits

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


[Lldb-commits] [lldb] cf5d8de - [lldb-vscode] Show a fake child with the raw value of synthetic types (#65552)

2023-09-06 Thread via lldb-commits

Author: Walter Erquinigo
Date: 2023-09-06T20:13:48-04:00
New Revision: cf5d8def5cf66fbdfffa00a4845bd648ec58ed60

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

LOG: [lldb-vscode] Show a fake child with the raw value of synthetic types 
(#65552)

Currently, if the user wants to inspect the raw version of a synthetic
variable, they have to go to the debug console and type `frame var
`, which is not a great experience. Taking inspiration from
CodeLLDB, this adds a `[raw]` child to every synthetic variable so that
this kind of inspection can be done visually.

Some examples:

https://github.com/llvm/llvm-project/assets/1613874/7fefb7c5-0da7-49c7-968b-78ac88348fea";>
https://github.com/llvm/llvm-project/assets/1613874/6e650567-16e1-462f-9bf5-4a3a605cf6fc";>

Added: 


Modified: 
lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
lldb/tools/lldb-vscode/JSONUtils.cpp
lldb/tools/lldb-vscode/JSONUtils.h
lldb/tools/lldb-vscode/lldb-vscode.cpp

Removed: 




diff  --git a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py 
b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
index 6eb8e87190d0074..953f330e14a0f97 100644
--- a/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
+++ b/lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
@@ -517,6 +517,20 @@ def test_indexedVariables(self):
 }
 self.verify_variables(verify_locals, locals)
 
+# We also verify that we produce a "[raw]" fake child with the real
+# SBValue for the synthetic type.
+verify_children = {
+"[0]": {"equals": {"type": "int", "value": "0"}},
+"[1]": {"equals": {"type": "int", "value": "0"}},
+"[2]": {"equals": {"type": "int", "value": "0"}},
+"[3]": {"equals": {"type": "int", "value": "0"}},
+"[4]": {"equals": {"type": "int", "value": "0"}},
+"[raw]": {"contains": {"type": ["vector"]}},
+}
+children = 
self.vscode.request_variables(locals[2]["variablesReference"])["body"]["variables"]
+self.verify_variables(verify_children, children)
+
+
 @skipIfWindows
 @skipIfRemote
 def test_registers(self):

diff  --git a/lldb/tools/lldb-vscode/JSONUtils.cpp 
b/lldb/tools/lldb-vscode/JSONUtils.cpp
index 9a6fd26d2bd5864..e34448c9b7f2f85 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.cpp
+++ b/lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -1103,10 +1103,13 @@ std::string 
CreateUniqueVariableNameForDisplay(lldb::SBValue v,
 // }
 llvm::json::Value CreateVariable(lldb::SBValue v, int64_t variablesReference,
  int64_t varID, bool format_hex,
- bool is_name_duplicated) {
+ bool is_name_duplicated,
+ std::optional custom_name) {
   llvm::json::Object object;
-  EmplaceSafeString(object, "name",
-CreateUniqueVariableNameForDisplay(v, is_name_duplicated));
+  EmplaceSafeString(
+  object, "name",
+  custom_name ? *custom_name
+  : CreateUniqueVariableNameForDisplay(v, is_name_duplicated));
 
   if (format_hex)
 v.SetFormat(lldb::eFormatHex);
@@ -1131,15 +1134,19 @@ llvm::json::Value CreateVariable(lldb::SBValue v, 
int64_t variablesReference,
   const bool is_synthetic = v.IsSynthetic();
   if (is_array || is_synthetic) {
 const auto num_children = v.GetNumChildren();
+// We create a "[raw]" fake child for each synthetic type, so we have to
+// account for it when returning indexed variables. We don't need to do 
this
+// for non-indexed ones.
+int actual_num_children = num_children + (is_synthetic ? 1 : 0);
 if (is_array) {
-  object.try_emplace("indexedVariables", num_children);
+  object.try_emplace("indexedVariables", actual_num_children);
 } else if (num_children > 0) {
   // If a type has a synthetic child provider, then the SBType of "v" won't
   // tell us anything about what might be displayed. So we can check if the
   // first child's name is "[0]" and then we can say it is indexed.
   const char *first_child_name = v.GetChildAtIndex(0).GetName();
   if (first_child_name && strcmp(first_child_name, "[0]") == 0)
-object.try_emplace("indexedVariables", num_children);
+object.try_emplace("indexedVariables", actual_num_children);
 }
   }
   EmplaceSafeString(object, "type", type_cstr ? type_cstr : NO_TYPENAME);

diff  --git a/lldb/tools/lldb-vscode/JSONUtils.h 
b/lldb/tools/lldb-vscode/JSONUtils.h
index 516bc462eae1b16..2013147f5d3532a 100644
--- a/lldb/tools/lldb-vscode/JSONUtils.h
+++ b/lldb/tools/lldb-vscode/JSONUtils.h
@@ -440,12 +440,17 @@ std::string 
Create

[Lldb-commits] [lldb] [lldb][NFCI] Remove typedef for TypeCategoryMap::ValueSP (PR #65555)

2023-09-06 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb][NFCI] Remove typedef for TypeCategoryMap::ValueSP (PR #65555)

2023-09-06 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb][NFCI] Remove typedef for TypeCategoryMap::ValueSP (PR #65555)

2023-09-06 Thread via lldb-commits

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

lldb already has a `ValueSP` type. This was confusing to me when reading 
TypeCategoryMap, especially when `ValueSP` is not qualified. From first glance 
it looks like it's referring to a `std::shared_ptr` when 
it's really referring to a `std::shared_ptr`.

>From 818c728e55ab78b9a20a542a1b6829981994094b Mon Sep 17 00:00:00 2001
From: Alex Langford 
Date: Wed, 6 Sep 2023 17:07:09 -0700
Subject: [PATCH] [lldb][NFCI] Remove typedef for TypeCategoryMap::ValueSP

lldb already has a `ValueSP` type. This was confusing to me
when reading TypeCategoryMap, especially when `ValueSP` is not
qualified. From first glance it looks like it's referring to a
`std::shared_ptr` when it's really referring to a
`std::shared_ptr`.
---
 lldb/include/lldb/DataFormatters/FormatManager.h |  2 +-
 .../lldb/DataFormatters/TypeCategoryMap.h| 14 ++
 lldb/source/DataFormatters/TypeCategoryMap.cpp   | 16 
 3 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/lldb/include/lldb/DataFormatters/FormatManager.h 
b/lldb/include/lldb/DataFormatters/FormatManager.h
index 295d3b84342a5d2..986614f0c5e431f 100644
--- a/lldb/include/lldb/DataFormatters/FormatManager.h
+++ b/lldb/include/lldb/DataFormatters/FormatManager.h
@@ -57,7 +57,7 @@ class FormatManager : public IFormatChangeListener {
 
   void EnableCategory(ConstString category_name,
   TypeCategoryMap::Position pos, lldb::LanguageType lang) {
-TypeCategoryMap::ValueSP category_sp;
+lldb::TypeCategoryImplSP category_sp;
 if (m_categories_map.Get(category_name, category_sp) && category_sp) {
   m_categories_map.Enable(category_sp, pos);
   category_sp->AddLanguage(lang);
diff --git a/lldb/include/lldb/DataFormatters/TypeCategoryMap.h 
b/lldb/include/lldb/DataFormatters/TypeCategoryMap.h
index 363d841b198a297..efd01f321da92f1 100644
--- a/lldb/include/lldb/DataFormatters/TypeCategoryMap.h
+++ b/lldb/include/lldb/DataFormatters/TypeCategoryMap.h
@@ -29,11 +29,9 @@ class TypeCategoryMap {
 
 public:
   typedef ConstString KeyType;
-  typedef TypeCategoryImpl ValueType;
-  typedef ValueType::SharedPointer ValueSP;
-  typedef std::map MapType;
+  typedef std::map MapType;
   typedef MapType::iterator MapIterator;
-  typedef std::function ForEachCallback;
+  typedef std::function 
ForEachCallback;
 
   typedef uint32_t Position;
 
@@ -43,7 +41,7 @@ class TypeCategoryMap {
 
   TypeCategoryMap(IFormatChangeListener *lst);
 
-  void Add(KeyType name, const ValueSP &entry);
+  void Add(KeyType name, const lldb::TypeCategoryImplSP &entry);
 
   bool Delete(KeyType name);
 
@@ -51,9 +49,9 @@ class TypeCategoryMap {
 
   bool Disable(KeyType category_name);
 
-  bool Enable(ValueSP category, Position pos = Default);
+  bool Enable(lldb::TypeCategoryImplSP category, Position pos = Default);
 
-  bool Disable(ValueSP category);
+  bool Disable(lldb::TypeCategoryImplSP category);
 
   void EnableAllCategories();
 
@@ -61,7 +59,7 @@ class TypeCategoryMap {
 
   void Clear();
 
-  bool Get(KeyType name, ValueSP &entry);
+  bool Get(KeyType name, lldb::TypeCategoryImplSP &entry);
 
   void ForEach(ForEachCallback callback);
 
diff --git a/lldb/source/DataFormatters/TypeCategoryMap.cpp 
b/lldb/source/DataFormatters/TypeCategoryMap.cpp
index c3de9196e39c553..fd76bab95826af7 100644
--- a/lldb/source/DataFormatters/TypeCategoryMap.cpp
+++ b/lldb/source/DataFormatters/TypeCategoryMap.cpp
@@ -24,7 +24,7 @@ TypeCategoryMap::TypeCategoryMap(IFormatChangeListener *lst)
   Enable(default_cs, First);
 }
 
-void TypeCategoryMap::Add(KeyType name, const ValueSP &entry) {
+void TypeCategoryMap::Add(KeyType name, const TypeCategoryImplSP &entry) {
   std::lock_guard guard(m_map_mutex);
   m_map[name] = entry;
   if (listener)
@@ -45,7 +45,7 @@ bool TypeCategoryMap::Delete(KeyType name) {
 
 bool TypeCategoryMap::Enable(KeyType category_name, Position pos) {
   std::lock_guard guard(m_map_mutex);
-  ValueSP category;
+  TypeCategoryImplSP category;
   if (!Get(category_name, category))
 return false;
   return Enable(category, pos);
@@ -53,13 +53,13 @@ bool TypeCategoryMap::Enable(KeyType category_name, 
Position pos) {
 
 bool TypeCategoryMap::Disable(KeyType category_name) {
   std::lock_guard guard(m_map_mutex);
-  ValueSP category;
+  TypeCategoryImplSP category;
   if (!Get(category_name, category))
 return false;
   return Disable(category);
 }
 
-bool TypeCategoryMap::Enable(ValueSP category, Position pos) {
+bool TypeCategoryMap::Enable(TypeCategoryImplSP category, Position pos) {
   std::lock_guard guard(m_map_mutex);
   if (category.get()) {
 Position pos_w = pos;
@@ -81,7 +81,7 @@ bool TypeCategoryMap::Enable(ValueSP category, Position pos) {
   return false;
 }
 
-bool TypeCategoryMap::Disable(ValueSP category) {
+bool TypeCategoryMap::Disable(TypeCategoryImplSP category) {
   std::lock_guard guard(m_map_mutex);
   if (category

[Lldb-commits] [lldb] [lldb][NFCI] Remove typedef for TypeCategoryMap::ValueSP (PR #65555)

2023-09-06 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb][NFCI] Remove typedef for TypeCategoryMap::ValueSP (PR #65555)

2023-09-06 Thread via lldb-commits

https://github.com/github-actions[bot] labeled 
https://github.com/llvm/llvm-project/pull/6
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Sang Ik Lee via lldb-commits

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


[Lldb-commits] [lldb] [lldb][NFCI] Remove typedef for TypeCategoryMap::ValueSP (PR #65555)

2023-09-06 Thread Jonas Devlieghere via lldb-commits

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

I started looking at the diff before reading the description only to be 
confused by the exact same thing. 

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


[Lldb-commits] [lldb] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Ronan Keryell via lldb-commits

https://github.com/keryell commented:

Quite interesting!
At some point it would be nice to have some design document or documentation 
somewhere explaining how all these MLIR runners works, including this one.
Globally this PR add a SYCL runner, but it is very specific for Intel Level 0.
It would be nice to have in the future some generalization, like SYCL using 
OpenCL interoperability interface to run the SPIR-V kernels or even native 
kernels.

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


[Lldb-commits] [lldb] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Ronan Keryell via lldb-commits


@@ -116,6 +116,7 @@ 
add_definitions(-DMLIR_ROCM_CONVERSIONS_ENABLED=${MLIR_ENABLE_ROCM_CONVERSIONS})
 
 set(MLIR_ENABLE_CUDA_RUNNER 0 CACHE BOOL "Enable building the mlir CUDA 
runner")
 set(MLIR_ENABLE_ROCM_RUNNER 0 CACHE BOOL "Enable building the mlir ROCm 
runner")
+set(MLIR_ENABLE_SYCL_RUNNER 0 CACHE BOOL "Enable building the mlir Sycl 
runner")

keryell wrote:

Please spell SYCL correctly.
```suggestion
set(MLIR_ENABLE_SYCL_RUNNER 0 CACHE BOOL "Enable building the mlir SYCL runner")
```
One could argue that `mlir` should be spelled `MLIR` but the train seems to 
have left long time ago. :-)

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


[Lldb-commits] [lldb] [MLIR] Enabling Intel GPU Integration. (PR #65539)

2023-09-06 Thread Ronan Keryell via lldb-commits

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


  1   2   >