[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Implement ExternalSemaSource::ReadUndefinedButUsed (PR #104817)

2024-08-20 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [llvm-lit][test] Change unsupported cat -e to cat -v to work with lit internal shell (PR #104878)

2024-08-20 Thread James Henderson via lldb-commits

https://github.com/jh7370 commented:

Looks reasonable to me, but I think it would be worth highlighting in the text 
the difference between -e and -v, so that people doing code archaelogy don't 
have to look up cat options.

Probably should get an lldb maintainer to approve though.

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


[Lldb-commits] [lldb] [llvm-lit][test] Change unsupported cat -e to cat -v to work with lit internal shell (PR #104878)

2024-08-20 Thread Petr Hosek via lldb-commits

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

LGTM but I'd wait for @JDevlieghere to respond.

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


[Lldb-commits] [lldb] WIP: [lldb][test] Workaround older systems that lack gettid (PR #104831)

2024-08-20 Thread Petr Hosek via lldb-commits


@@ -1,3 +1,14 @@
+include(CheckSymbolExists)
+include(CMakePushCheckState)
+
+cmake_push_check_state()
+set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
+check_symbol_exists(gettid "unistd.h" HAVE_GETTID)
+if(HAVE_GETTID)
+  add_compile_definitions(-DHAVE_GETTID)

petrhosek wrote:

You can make this more targeted by applying it only to `ProcessElfCoreTests` 
with `target_compile_definitions`, but either way is fine with me.

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


[Lldb-commits] [lldb] WIP: [lldb][test] Workaround older systems that lack gettid (PR #104831)

2024-08-20 Thread Petr Hosek via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][AIX] 1. Avoid namespace collision on other platforms (PR #104679)

2024-08-20 Thread David Spickett via lldb-commits

DavidSpickett wrote:

> The code format test passed but, I see some new failures (mostly in lldb-api 
> and some in lldb-shell), which were not there in the previous run.

Not sure if you mean in the GitHub CI or locally, but either way I doubt they 
are due to your change. I'll see what the current CI run does.

> Could it be because my branch is not up to date?

Well, it could in fact be because your branch *is* up to date :) LLVM is a 
"live at head" sort of model where the main branch can be all kinds of broken 
depending on when you pull it. We fix these issues pretty fast but you can 
still be unlucky.

The advice is not to rebase the PR if you can avoid it: 
https://llvm.org/docs/GitHub.html#rebasing-pull-requests-and-force-pushes

But for example if you post a PR and the very first CI run has failures, it 
would be fine to rebase it before any significant review has taken place. Just 
to make it clear the issues are not your fault. Or if the comments were all 
addressed, etc, you'll get a feel for it over time.

> How can I avoid such failures for future PRs?

Don't rebase unless you have to. If when you land the PR things fail because 
some later change interacts with yours, that's fine that's what the post commit 
Buildbots are intended to catch.

The other side effect of llvm being "live at head" is that reverts are very 
common, so if they happen don't be discouraged, it happens to everyone. I wrote 
this up in more verbose terms in 
https://llvm.org/docs/MyFirstTypoFix.html#issues-after-landing-your-pr.

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


[Lldb-commits] [lldb] [lldb][AIX] 1. Avoid namespace collision on other platforms (PR #104679)

2024-08-20 Thread David Spickett via lldb-commits

DavidSpickett wrote:

(and I will merge this once I see that CI is happy, or unhappy in a way not 
related to your changes)

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


[Lldb-commits] [lldb] [llvm-lit][test] Change unsupported cat -e to cat -v to work with lit internal shell (PR #104878)

2024-08-20 Thread David Spickett via lldb-commits

DavidSpickett wrote:

I think Jonas might be on vacation at the moment, I can do a reasonable 
impression in the meantime :)

For GNU cat, `-e` is equivalent to `-eV`. `e` prints the non-printable 
characters and `v` puts `$` on the end of the line.
```
-e equivalent to -vE
<...>
-E, --show-ends
  display $ at end of each line
-v, --show-nonprinting
  use ^ and M- notation, except for LFD and TAB
```

For Mac (https://www.unix.com/man-page/osx/1/cat/) and BSD 
(https://man.freebsd.org/cgi/man.cgi?cat(1)), `-e` is `-v` with the addition of 
adding `$` on the end. There's no separate `-E` option.

It has been `cat -e` since the test was added in 
https://github.com/llvm/llvm-project/commit/de019b88dd5804ec996fe8c12cddcc6feb13afa1
 / https://reviews.llvm.org/D81058.

Using `-v` works fine because the test does not look for the `$` on the end of 
the line, just the (usually) non-printable colour characters.

So I don't think there is any problem with landing this, once you add the 
option explanation to the PR description.

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


[Lldb-commits] [lldb] [lldb][test] Change unsupported cat -e to cat -v to work with lit internal shell (PR #104878)

2024-08-20 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Change unsupported cat -e to cat -v to work with lit internal shell (PR #104878)

2024-08-20 Thread David Spickett via lldb-commits

DavidSpickett wrote:

And I just edited the title slightly, since this is changing an lldb test not 
llvm-lit itself.

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


[Lldb-commits] [lldb] [lldb][test] Change unsupported cat -e to cat -v to work with lit internal shell (PR #104878)

2024-08-20 Thread David Spickett via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][AIX] 1. Avoid namespace collision on other platforms (PR #104679)

2024-08-20 Thread David Spickett via lldb-commits

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


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


[Lldb-commits] [lldb] b804516 - [lldb][AIX] 1. Avoid namespace collision on other platforms (#104679)

2024-08-20 Thread via lldb-commits

Author: Dhruv Srivastava
Date: 2024-08-20T10:19:32+01:00
New Revision: b804516dc5cf2bb99ff02aa49f9d4da76d721ea9

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

LOG: [lldb][AIX] 1. Avoid namespace collision on other platforms (#104679)

This PR is in reference to porting LLDB on AIX.

Link to discussions on llvm discourse and github:
1.  https://discourse.llvm.org/t/port-lldb-to-ibm-aix/80640
2.  #101657 

The complete changes for porting are present in this draft PR:
https://github.com/llvm/llvm-project/pull/102601

The changes on this PR are intended to avoid namespace collision for
certain typedefs between lldb and other platforms:
1. tid_t --> lldb::tid_t
2. offset_t --> lldb::offset_t

Added: 


Modified: 
lldb/source/API/SBBreakpoint.cpp
lldb/source/API/SBBreakpointLocation.cpp
lldb/source/API/SBBreakpointName.cpp
lldb/source/Expression/DWARFExpression.cpp
lldb/source/Plugins/ABI/PowerPC/ABISysV_ppc64.cpp

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp

lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp

lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp

lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
lldb/source/Plugins/Process/Utility/ThreadMemory.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
lldb/source/Plugins/SystemRuntime/MacOSX/AppleGetThreadItemInfoHandler.cpp
lldb/source/Symbol/DWARFCallFrameInfo.cpp

Removed: 




diff  --git a/lldb/source/API/SBBreakpoint.cpp 
b/lldb/source/API/SBBreakpoint.cpp
index 3d908047f9455b..728fe04d14d927 100644
--- a/lldb/source/API/SBBreakpoint.cpp
+++ b/lldb/source/API/SBBreakpoint.cpp
@@ -342,7 +342,7 @@ uint32_t SBBreakpoint::GetIgnoreCount() const {
   return count;
 }
 
-void SBBreakpoint::SetThreadID(tid_t tid) {
+void SBBreakpoint::SetThreadID(lldb::tid_t tid) {
   LLDB_INSTRUMENT_VA(this, tid);
 
   BreakpointSP bkpt_sp = GetSP();
@@ -353,10 +353,10 @@ void SBBreakpoint::SetThreadID(tid_t tid) {
   }
 }
 
-tid_t SBBreakpoint::GetThreadID() {
+lldb::tid_t SBBreakpoint::GetThreadID() {
   LLDB_INSTRUMENT_VA(this);
 
-  tid_t tid = LLDB_INVALID_THREAD_ID;
+  lldb::tid_t tid = LLDB_INVALID_THREAD_ID;
   BreakpointSP bkpt_sp = GetSP();
   if (bkpt_sp) {
 std::lock_guard guard(

diff  --git a/lldb/source/API/SBBreakpointLocation.cpp 
b/lldb/source/API/SBBreakpointLocation.cpp
index 75b66364d4f1ae..fad9a4076a54fb 100644
--- a/lldb/source/API/SBBreakpointLocation.cpp
+++ b/lldb/source/API/SBBreakpointLocation.cpp
@@ -302,7 +302,7 @@ bool 
SBBreakpointLocation::GetCommandLineCommands(SBStringList &commands) {
   return has_commands;
 }
 
-void SBBreakpointLocation::SetThreadID(tid_t thread_id) {
+void SBBreakpointLocation::SetThreadID(lldb::tid_t thread_id) {
   LLDB_INSTRUMENT_VA(this, thread_id);
 
   BreakpointLocationSP loc_sp = GetSP();
@@ -313,10 +313,10 @@ void SBBreakpointLocation::SetThreadID(tid_t thread_id) {
   }
 }
 
-tid_t SBBreakpointLocation::GetThreadID() {
+lldb::tid_t SBBreakpointLocation::GetThreadID() {
   LLDB_INSTRUMENT_VA(this);
 
-  tid_t tid = LLDB_INVALID_THREAD_ID;
+  lldb::tid_t tid = LLDB_INVALID_THREAD_ID;
   BreakpointLocationSP loc_sp = GetSP();
   if (loc_sp) {
 std::lock_guard guard(

diff  --git a/lldb/source/API/SBBreakpointName.cpp 
b/lldb/source/API/SBBreakpointName.cpp
index 7f63aaf6fa7d5e..5c7c0a8f6504b0 100644
--- a/lldb/source/API/SBBreakpointName.cpp
+++ b/lldb/source/API/SBBreakpointName.cpp
@@ -347,7 +347,7 @@ bool SBBreakpointName::GetAutoContinue() {
   return bp_name->GetOptions().IsAutoContinue();
 }
 
-void SBBreakpointName::SetThreadID(tid_t tid) {
+void SBBreakpointName::SetThreadID(lldb::tid_t tid) {
   LLDB_INSTRUMENT_VA(this, tid);
 
   BreakpointName *bp_name = GetBreakpointName();
@@ -361,7 +361,7 @@ void SBBreakpointName::SetThreadID(tid_t tid) {
   UpdateName(*bp_name);
 }
 
-tid_t SBBreakpointName::GetThreadID() {
+lldb::tid_t SBBreakpointName::GetThreadID() {
   LLDB_INSTRUMENT_VA(this);
 
   BreakpointName *bp_name = GetBreakpointName();

diff  --git a/lldb/source/Expression/DWARFExpression.cpp 
b/lldb/source/Expression/DWARFExpression.cpp
index 444e44b3928919..22d899f799d0fd 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpress

[Lldb-commits] [lldb] [lldb][AIX] 1. Avoid namespace collision on other platforms (PR #104679)

2024-08-20 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][AIX] 1. Avoid namespace collision on other platforms (PR #104679)

2024-08-20 Thread via lldb-commits

github-actions[bot] wrote:



@DhruvSrivastavaX Congratulations on having your first Pull Request (PR) merged 
into the LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested
by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with 
a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself.
This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


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


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

2024-08-20 Thread Adrian Vogelsgesang via lldb-commits

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


[Lldb-commits] [lldb] [lldb][AIX] 1. Avoid namespace collision on other platforms (PR #104679)

2024-08-20 Thread Dhruv Srivastava via lldb-commits

DhruvSrivastavaX wrote:

Ok thats a relief to hear. 

> Not sure if you mean in the GitHub CI or locally

Yes I was referring to the Github CI right now. 

Great, The first PR is happily merged.
Thanks alot for all of the help and inputs!!

We can now get started with the rest of the PRs since I got some clarity now. 



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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the API test breakpoint_with_realpath_and_source_map (PR #104918)

2024-08-20 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman created 
https://github.com/llvm/llvm-project/pull/104918

This test is already disabled for Windows because of symlinks. Disable it for 
cross build on Windows host too.

>From e6e607af0288d0102751487d4851e133eab2244c Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Tue, 20 Aug 2024 16:11:53 +0400
Subject: [PATCH] [lldb][Windows] Fixed the API test
 breakpoint_with_realpath_and_source_map

This test is already disabled for Windows because of symlinks. Disable it for 
cross build on Windows host too.
---
 .../breakpoint_with_realpath_and_source_map/TestBreakpoint.py| 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
 
b/lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
index 5dc2af73f3647d..d31df52c3b338e 100644
--- 
a/lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
+++ 
b/lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
@@ -32,6 +32,7 @@ def buildAndCreateTarget(self):
 self.assertTrue(target, VALID_TARGET)
 
 @skipIf(oslist=["windows"])
+@skipIf(hostoslist=['windows'])
 def test_file_line_breakpoint_realpath_and_source_map(self):
 """Test file/line breakpoint with realpathing and source-mapping."""
 self.buildAndCreateTarget()

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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the API test breakpoint_with_realpath_and_source_map (PR #104918)

2024-08-20 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

This test is already disabled for Windows because of symlinks. Disable it for 
cross build on Windows host too.

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


1 Files Affected:

- (modified) 
lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
 (+1) 


``diff
diff --git 
a/lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
 
b/lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
index 5dc2af73f3647d..d31df52c3b338e 100644
--- 
a/lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
+++ 
b/lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
@@ -32,6 +32,7 @@ def buildAndCreateTarget(self):
 self.assertTrue(target, VALID_TARGET)
 
 @skipIf(oslist=["windows"])
+@skipIf(hostoslist=['windows'])
 def test_file_line_breakpoint_realpath_and_source_map(self):
 """Test file/line breakpoint with realpathing and source-mapping."""
 self.buildAndCreateTarget()

``




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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the API test breakpoint_with_realpath_and_source_map (PR #104918)

2024-08-20 Thread David Spickett via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the API test breakpoint_with_realpath_and_source_map (PR #104918)

2024-08-20 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman updated 
https://github.com/llvm/llvm-project/pull/104918

>From dd5070e26b41f6022f09b797772378076348298b Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Tue, 20 Aug 2024 16:11:53 +0400
Subject: [PATCH] [lldb][Windows] Fixed the API test
 breakpoint_with_realpath_and_source_map

This test is already disabled for Windows because of symlinks. Disable it for 
cross build on Windows host too.
---
 .../breakpoint_with_realpath_and_source_map/TestBreakpoint.py| 1 +
 1 file changed, 1 insertion(+)

diff --git 
a/lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
 
b/lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
index 5dc2af73f3647d..b95a97d9dae7b1 100644
--- 
a/lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
+++ 
b/lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
@@ -32,6 +32,7 @@ def buildAndCreateTarget(self):
 self.assertTrue(target, VALID_TARGET)
 
 @skipIf(oslist=["windows"])
+@skipIf(hostoslist=["windows"])
 def test_file_line_breakpoint_realpath_and_source_map(self):
 """Test file/line breakpoint with realpathing and source-mapping."""
 self.buildAndCreateTarget()

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


[Lldb-commits] [lldb] fc04490 - [lldb][Windows] Fixed the API test breakpoint_with_realpath_and_source_map (#104918)

2024-08-20 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2024-08-20T17:25:34+04:00
New Revision: fc044901a2b8ae277b62bdde9140917913bd1644

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

LOG: [lldb][Windows] Fixed the API test breakpoint_with_realpath_and_source_map 
(#104918)

This test is already disabled for Windows because of symlinks. Disable
it for cross build on Windows host too.

Added: 


Modified: 

lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
 
b/lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
index 5dc2af73f3647d..b95a97d9dae7b1 100644
--- 
a/lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
+++ 
b/lldb/test/API/functionalities/breakpoint/breakpoint_with_realpath_and_source_map/TestBreakpoint.py
@@ -32,6 +32,7 @@ def buildAndCreateTarget(self):
 self.assertTrue(target, VALID_TARGET)
 
 @skipIf(oslist=["windows"])
+@skipIf(hostoslist=["windows"])
 def test_file_line_breakpoint_realpath_and_source_map(self):
 """Test file/line breakpoint with realpathing and source-mapping."""
 self.buildAndCreateTarget()



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


[Lldb-commits] [lldb] [lldb][Windows] Fixed the API test breakpoint_with_realpath_and_source_map (PR #104918)

2024-08-20 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Disable the API test TestCppBitfields on Windows (PR #105037)

2024-08-20 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman created 
https://github.com/llvm/llvm-project/pull/105037

This test causes the assert in clang CodeGen and python crashes with the error 
code 0x8003. See #105019 for more details. Note the similar test 
lldb/test/API/lang/c/bitfields/TestBitfields.py is already disabled on Windows.

>From 9e91ad6940a05748bdac6c1597bded749ac333dc Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Tue, 20 Aug 2024 19:48:20 +0400
Subject: [PATCH] [lldb] Disable the API test TestCppBitfields on Windows

This test causes the assert in clang CodeGen and python crashes with the error 
code 0x8003. See #105019 for more details.
Note the similar test lldb/test/API/lang/c/bitfields/TestBitfields.py is 
already disabled on Windows.
---
 lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py 
b/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
index f796c635895ac1..dba1422a0d52a1 100644
--- a/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
+++ b/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
@@ -8,6 +8,7 @@
 
 class CppBitfieldsTestCase(TestBase):
 @no_debug_info_test
+@skipIf(oslist=["windows"], 
bugnumber="github.com/llvm/llvm-project/issues/105019")
 def test_bitfields(self):
 self.build()
 lldbutil.run_to_source_breakpoint(

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


[Lldb-commits] [lldb] [lldb] Disable the API test TestCppBitfields on Windows (PR #105037)

2024-08-20 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

This test causes the assert in clang CodeGen and python crashes with the error 
code 0x8003. See #105019 for more details. Note the similar test 
lldb/test/API/lang/c/bitfields/TestBitfields.py is already disabled on Windows.

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


1 Files Affected:

- (modified) lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py (+1) 


``diff
diff --git a/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py 
b/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
index f796c635895ac1..dba1422a0d52a1 100644
--- a/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
+++ b/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
@@ -8,6 +8,7 @@
 
 class CppBitfieldsTestCase(TestBase):
 @no_debug_info_test
+@skipIf(oslist=["windows"], 
bugnumber="github.com/llvm/llvm-project/issues/105019")
 def test_bitfields(self):
 self.build()
 lldbutil.run_to_source_breakpoint(

``




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


[Lldb-commits] [lldb] Fix dap stacktrace perf issue (PR #104874)

2024-08-20 Thread Walter Erquinigo via lldb-commits

walter-erquinigo wrote:

@ashgti , do you have any opinions on this?


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


[Lldb-commits] [lldb] Fix dap stacktrace perf issue (PR #104874)

2024-08-20 Thread Walter Erquinigo via lldb-commits

https://github.com/walter-erquinigo requested changes to this pull request.

@jeffreytan81 , could you make the default to be true if the current platform 
is Mac? The extension should just work nicely for the 99% of people who don't 
use massive binaries.

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Adrian Prantl via lldb-commits

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

>From ece2b891557ee8323ff7d2d67b66cb01d06502a9 Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 15 Aug 2024 16:18:33 -0700
Subject: [PATCH] [lldb] Extend frame recognizers to hide frames from
 backtraces

Compilers and language runtimes often use helper functions that are
fundamentally uninteresting when debugging anything but the
compiler/runtime itself. This patch introduces a user-extensible
mechanism that allows for these frames to be hidden from backtraces
and automatically skipped over when navigating the stack with `up` and
`down`, and when stepping out of the current frame.

This does not affect the numbering of frames, so `f ` will still
provide access to the hidden frames. The `bt` output will also print a
hint that frames have been hidden.

My primary motivation for this feature is to hide thunks in the Swift
programming language, but I'm including an example recognizer for
`std::function::operator()` that I wished for myself many times while
debugging LLDB.

The functionality is user-extensible via Python recognizers and
exposed through the SBAPI via SBFrame::IsHidden().

rdar://126629381
---
 lldb/bindings/python/python-wrapper.swig  | 18 +++-
 lldb/include/lldb/API/SBFrame.h   |  4 +
 .../lldb/Interpreter/ScriptInterpreter.h  |  5 ++
 lldb/include/lldb/Target/StackFrame.h | 33 
 lldb/include/lldb/Target/StackFrameList.h |  2 +-
 .../lldb/Target/StackFrameRecognizer.h| 20 +++--
 lldb/include/lldb/Target/Thread.h |  5 +-
 lldb/source/API/SBFrame.cpp   | 13 +++
 lldb/source/API/SBThread.cpp  |  3 +-
 lldb/source/Commands/CommandCompletions.cpp   |  4 +-
 lldb/source/Commands/CommandObjectFrame.cpp   | 23 +
 lldb/source/Commands/CommandObjectMemory.cpp  |  3 +-
 lldb/source/Commands/CommandObjectThread.cpp  | 19 -
 lldb/source/Commands/Options.td   |  2 +
 lldb/source/Core/Debugger.cpp |  3 +-
 .../source/Interpreter/CommandInterpreter.cpp |  9 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 44 +-
 .../Python/SWIGPythonBridge.h |  3 +
 .../Python/ScriptInterpreterPython.cpp| 29 +++
 .../Python/ScriptInterpreterPythonImpl.h  |  3 +
 lldb/source/Target/Process.cpp|  7 +-
 lldb/source/Target/StackFrame.cpp | 26 --
 lldb/source/Target/StackFrameList.cpp |  8 +-
 lldb/source/Target/StackFrameRecognizer.cpp   | 30 +--
 lldb/source/Target/Thread.cpp | 13 +--
 lldb/source/Target/ThreadPlanStepOut.cpp  |  2 +-
 .../frame/recognizer/TestFrameRecognizer.py   | 40 +
 .../test/API/commands/frame/recognizer/main.m | 21 ++---
 .../commands/frame/recognizer/recognizer.py   |  5 ++
 .../lang/cpp/std-function-recognizer/Makefile |  4 +
 .../TestStdFunctionRecognizer.py  | 84 +++
 .../lang/cpp/std-function-recognizer/main.cpp | 10 +++
 32 files changed, 421 insertions(+), 74 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-function-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-function-recognizer/main.cpp

diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 8f050643fa68b3..2ce42e3e017d5b 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -813,7 +813,7 @@ PythonObject 
lldb_private::python::SWIGBridge::LLDBSWIGPython_CreateFrameRecogni
 }
 
 PyObject 
*lldb_private::python::SWIGBridge::LLDBSwigPython_GetRecognizedArguments(
-PyObject * implementor, const lldb::StackFrameSP &frame_sp) {
+PyObject *implementor, const lldb::StackFrameSP &frame_sp) {
   static char callee_name[] = "get_recognized_arguments";
 
   PythonObject arg = SWIGBridge::ToSWIGWrapper(frame_sp);
@@ -824,6 +824,22 @@ PyObject 
*lldb_private::python::SWIGBridge::LLDBSwigPython_GetRecognizedArgument
   return result;
 }
 
+bool lldb_private::python::SWIGBridge::LLDBSwigPython_ShouldHide(
+PyObject *implementor, const lldb::StackFrameSP &frame_sp) {
+  static char callee_name[] = "should_hide";
+
+  PythonObject arg = SWIGBridge::ToSWIGWrapper(frame_sp);
+
+  PythonString str(callee_name);
+
+  PyObject *result =
+  PyObject_CallMethodObjArgs(implementor, str.get(), arg.get(), NULL);
+  bool ret_val = result ? PyObject_IsTrue(result) : false;
+  Py_XDECREF(result);
+
+  return result;
+}
+
 void *lldb_private::python::SWIGBridge::LLDBSWIGPython_GetDynamicSetting(
 void *module, const char *setting, const lldb::TargetSP &target_sp) {
   if (!module || !setting)
diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h
index 821ff3cf7ce519..e0d15c3ecc5b1c 100644
--- a/lldb/include/lldb/API/SBFrame.h
+++ b/lldb/include

[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

Implemented StepOut.

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


[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Don't leak memory when multiplexing ExternalASTSources (PR #104799)

2024-08-20 Thread Adrian Prantl via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Implement ExternalSemaSource::ReadUndefinedButUsed (PR #104817)

2024-08-20 Thread Adrian Prantl via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][test] Change unsupported cat -e to cat -v to work with lit internal shell (PR #104878)

2024-08-20 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Change unsupported cat -e to cat -v to work with lit internal shell (PR #104878)

2024-08-20 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Change unsupported cat -e to cat -v to work with lit internal shell (PR #104878)

2024-08-20 Thread via lldb-commits

connieyzhu wrote:

> Looks reasonable to me, but I think it would be worth highlighting in the 
> text the difference between -e and -v, so that people doing code archaelogy 
> don't have to look up cat options.

I just added the option description in the PR description - thanks for the 
feedback!


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


[Lldb-commits] [lldb] [lldb][test] Change unsupported cat -e to cat -v to work with lit internal shell (PR #104878)

2024-08-20 Thread via lldb-commits

connieyzhu wrote:

> And I edited the title slightly, since this is changing an lldb test not 
> llvm-lit itself.

Totally missed that somehow, thank you for the fix!

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Adrian Prantl via lldb-commits

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

>From 81af1010aad7f6ab1abcf397c81245e53cc29adc Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 15 Aug 2024 16:18:33 -0700
Subject: [PATCH] [lldb] Extend frame recognizers to hide frames from
 backtraces

Compilers and language runtimes often use helper functions that are
fundamentally uninteresting when debugging anything but the
compiler/runtime itself. This patch introduces a user-extensible
mechanism that allows for these frames to be hidden from backtraces
and automatically skipped over when navigating the stack with `up` and
`down`, and when stepping out of the current frame.

This does not affect the numbering of frames, so `f ` will still
provide access to the hidden frames. The `bt` output will also print a
hint that frames have been hidden.

My primary motivation for this feature is to hide thunks in the Swift
programming language, but I'm including an example recognizer for
`std::function::operator()` that I wished for myself many times while
debugging LLDB.

The functionality is user-extensible via Python recognizers and
exposed through the SBAPI via SBFrame::IsHidden().

rdar://126629381
---
 lldb/bindings/python/python-wrapper.swig  | 18 +++-
 lldb/include/lldb/API/SBFrame.h   |  4 +
 .../lldb/Interpreter/ScriptInterpreter.h  |  5 ++
 lldb/include/lldb/Target/StackFrame.h | 33 
 lldb/include/lldb/Target/StackFrameList.h |  2 +-
 .../lldb/Target/StackFrameRecognizer.h| 20 +++--
 lldb/include/lldb/Target/Thread.h |  4 +-
 lldb/source/API/SBFrame.cpp   | 13 +++
 lldb/source/API/SBThread.cpp  |  3 +-
 lldb/source/Commands/CommandCompletions.cpp   |  4 +-
 lldb/source/Commands/CommandObjectFrame.cpp   | 23 +
 lldb/source/Commands/CommandObjectMemory.cpp  |  3 +-
 lldb/source/Commands/CommandObjectThread.cpp  | 19 -
 lldb/source/Commands/Options.td   |  2 +
 lldb/source/Core/Debugger.cpp |  3 +-
 .../source/Interpreter/CommandInterpreter.cpp |  9 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 44 +-
 .../Python/SWIGPythonBridge.h |  3 +
 .../Python/ScriptInterpreterPython.cpp| 29 +++
 .../Python/ScriptInterpreterPythonImpl.h  |  3 +
 lldb/source/Target/Process.cpp|  7 +-
 lldb/source/Target/StackFrame.cpp | 26 --
 lldb/source/Target/StackFrameList.cpp |  8 +-
 lldb/source/Target/StackFrameRecognizer.cpp   | 30 +--
 lldb/source/Target/Thread.cpp | 12 +--
 lldb/source/Target/ThreadPlanStepOut.cpp  |  2 +-
 .../frame/recognizer/TestFrameRecognizer.py   | 40 +
 .../test/API/commands/frame/recognizer/main.m | 21 ++---
 .../commands/frame/recognizer/recognizer.py   |  5 ++
 .../lang/cpp/std-function-recognizer/Makefile |  4 +
 .../TestStdFunctionRecognizer.py  | 84 +++
 .../lang/cpp/std-function-recognizer/main.cpp | 10 +++
 32 files changed, 419 insertions(+), 74 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-function-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-function-recognizer/main.cpp

diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 8f050643fa68b3..2ce42e3e017d5b 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -813,7 +813,7 @@ PythonObject 
lldb_private::python::SWIGBridge::LLDBSWIGPython_CreateFrameRecogni
 }
 
 PyObject 
*lldb_private::python::SWIGBridge::LLDBSwigPython_GetRecognizedArguments(
-PyObject * implementor, const lldb::StackFrameSP &frame_sp) {
+PyObject *implementor, const lldb::StackFrameSP &frame_sp) {
   static char callee_name[] = "get_recognized_arguments";
 
   PythonObject arg = SWIGBridge::ToSWIGWrapper(frame_sp);
@@ -824,6 +824,22 @@ PyObject 
*lldb_private::python::SWIGBridge::LLDBSwigPython_GetRecognizedArgument
   return result;
 }
 
+bool lldb_private::python::SWIGBridge::LLDBSwigPython_ShouldHide(
+PyObject *implementor, const lldb::StackFrameSP &frame_sp) {
+  static char callee_name[] = "should_hide";
+
+  PythonObject arg = SWIGBridge::ToSWIGWrapper(frame_sp);
+
+  PythonString str(callee_name);
+
+  PyObject *result =
+  PyObject_CallMethodObjArgs(implementor, str.get(), arg.get(), NULL);
+  bool ret_val = result ? PyObject_IsTrue(result) : false;
+  Py_XDECREF(result);
+
+  return result;
+}
+
 void *lldb_private::python::SWIGBridge::LLDBSWIGPython_GetDynamicSetting(
 void *module, const char *setting, const lldb::TargetSP &target_sp) {
   if (!module || !setting)
diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h
index 821ff3cf7ce519..e0d15c3ecc5b1c 100644
--- a/lldb/include/lldb/API/SBFrame.h
+++ b/lldb/include

[Lldb-commits] [lldb] [lldb][test] Improve toolchain detection in Makefile.rules (PR #102185)

2024-08-20 Thread Vladislav Dzhidzhoev via lldb-commits

dzhidzhoev wrote:

Now this is ready for review.

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


[Lldb-commits] [lldb] [lldb][test] Change unsupported cat -e to cat -v to work with lit internal shell (PR #104878)

2024-08-20 Thread Connie Zhu via lldb-commits

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


[Lldb-commits] [lldb] [lldb][test] Change unsupported cat -e to cat -v to work with lit internal shell (PR #104878)

2024-08-20 Thread Connie Zhu via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix windows debug build after 9d07f43 (PR #104896)

2024-08-20 Thread Jonas Devlieghere via lldb-commits

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

LGTM!

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


[Lldb-commits] [lldb] [lldb] Fix windows debug build after 9d07f43 (PR #104896)

2024-08-20 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] 770cd24 - [lldb][ClangExpressionParser] Don't leak memory when multiplexing ExternalASTSources (#104799)

2024-08-20 Thread via lldb-commits

Author: Michael Buch
Date: 2024-08-20T18:40:54+01:00
New Revision: 770cd24140038646539602406fff54497793dae8

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

LOG: [lldb][ClangExpressionParser] Don't leak memory when multiplexing 
ExternalASTSources (#104799)

When we use `SemaSourceWithPriorities` as the `ASTContext`s
ExternalASTSource, we allocate a `ClangASTSourceProxy` (via
`CreateProxy`) and two `ExternalASTSourceWrapper`. Then we push these
sources into a vector in `SemaSourceWithPriorities`. The allocated
`SemaSourceWithPriorities` itself will get properly deallocated because
the `ASTContext` wraps it in an `IntrusiveRefCntPtr`. But the three
sources we allocated earlier will never get released.

This patch fixes this by mimicking what `MultiplexExternalSemaSource`
does (which is what `SemaSourceWithPriorities` is based on anyway).
I.e., when `SemaSourceWithPriorities` gets constructed, it increments
the use count of its sources. And on destruction it decrements them.

Similarly, to make sure we dealloacted the `ClangASTProxy` properly, the
`ExternalASTSourceWrapper` now assumes shared ownership of the
underlying source.

Added: 


Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.cpp
lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.cpp
index a95fce1c5aa966..5d67a51b269051 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.cpp
@@ -18,7 +18,10 @@ lldb_private::ASTConsumerForwarder::~ASTConsumerForwarder() 
= default;
 
 void lldb_private::ASTConsumerForwarder::PrintStats() { m_c->PrintStats(); }
 
-lldb_private::SemaSourceWithPriorities::~SemaSourceWithPriorities() = default;
+lldb_private::SemaSourceWithPriorities::~SemaSourceWithPriorities() {
+  for (auto *Source : Sources)
+Source->Release();
+}
 
 void lldb_private::SemaSourceWithPriorities::PrintStats() {
   for (size_t i = 0; i < Sources.size(); ++i)

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h 
b/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
index 79ed74b79f04fd..44e52e8dd65113 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
@@ -14,6 +14,7 @@
 #include "clang/Sema/MultiplexExternalSemaSource.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/SemaConsumer.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include 
 
 namespace clang {
@@ -24,13 +25,15 @@ class Module;
 
 namespace lldb_private {
 
-/// Wraps an ExternalASTSource into an ExternalSemaSource. Doesn't take
-/// ownership of the provided source.
+/// Wraps an ExternalASTSource into an ExternalSemaSource.
+///
+/// Assumes shared ownership of the underlying source.
 class ExternalASTSourceWrapper : public clang::ExternalSemaSource {
-  ExternalASTSource *m_Source;
+  llvm::IntrusiveRefCntPtr m_Source;
 
 public:
-  ExternalASTSourceWrapper(ExternalASTSource *Source) : m_Source(Source) {
+  explicit ExternalASTSourceWrapper(ExternalASTSource *Source)
+  : m_Source(Source) {
 assert(m_Source && "Can't wrap nullptr ExternalASTSource");
   }
 
@@ -256,10 +259,18 @@ class SemaSourceWithPriorities : public 
clang::ExternalSemaSource {
   /// Construct a SemaSourceWithPriorities with a 'high quality' source that
   /// has the higher priority and a 'low quality' source that will be used
   /// as a fallback.
-  SemaSourceWithPriorities(clang::ExternalSemaSource &high_quality_source,
-   clang::ExternalSemaSource &low_quality_source) {
-Sources.push_back(&high_quality_source);
-Sources.push_back(&low_quality_source);
+  ///
+  /// This class assumes shared ownership of the sources provided to it.
+  SemaSourceWithPriorities(clang::ExternalSemaSource *high_quality_source,
+   clang::ExternalSemaSource *low_quality_source) {
+assert(high_quality_source);
+assert(low_quality_source);
+
+high_quality_source->Retain();
+low_quality_source->Retain();
+
+Sources.push_back(high_quality_source);
+Sources.push_back(low_quality_source);
   }
 
   ~SemaSourceWithPriorities() override;

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index c441153d1efb05..d37787ebae26c3 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1224,15 +1224,15 @@ ClangExpressionPar

[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Don't leak memory when multiplexing ExternalASTSources (PR #104799)

2024-08-20 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Implement ExternalSemaSource::ReadUndefinedButUsed (PR #104817)

2024-08-20 Thread Michael Buch via lldb-commits

https://github.com/Michael137 updated 
https://github.com/llvm/llvm-project/pull/104817

>From 4bb7f6495a2fbf46e01b9f01c46d335d2b680afd Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 19 Aug 2024 17:39:44 +0100
Subject: [PATCH 1/3] [lldb][ClangExpressionParser] Implement
 ExternalSemaSource::ReadUndefinedButUsed

While parsing an expression, Clang tries to diagnose usage of decls
(with possibly non-external linkage) for which it hasn't been provided
with a definition. This is the case, e.g., for functions with parameters
that live in an anonymous namespace (those will have `UniqueExternal`
linkage). Before diagnosing such situations, Clang calls
`ExternalSemaSource::ReadUndefinedButUsed`. The intended use of this
API is to extend the set of "used but not defined" decls with additional
ones that the external source knows about. However, in LLDB's case,
we never provide `FunctionDecl`s with a definition, and instead
rely on the expression parser to resolve those symbols by linkage name.
Thus, to avoid the Clang parser from erroring out in these situations,
this patch implements `ReadUndefinedButUsed` which just removes the
"undefined" non-external `FunctionDecl`s that Clang found.

Fixes https://github.com/llvm/llvm-project/issues/104712
---
 .../Plugins/ExpressionParser/Clang/ASTUtils.h | 19 +++
 .../Clang/ClangExpressionParser.cpp   |  3 +++
 .../Shell/Expr/TestAnonNamespaceParamFunc.cpp | 19 +++
 3 files changed, 41 insertions(+)
 create mode 100644 lldb/test/Shell/Expr/TestAnonNamespaceParamFunc.cpp

diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h 
b/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
index 79ed74b79f04fd..9710f7dd4e983c 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
@@ -14,6 +14,7 @@
 #include "clang/Sema/MultiplexExternalSemaSource.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/SemaConsumer.h"
+#include "llvm/Support/Casting.h"
 #include 
 
 namespace clang {
@@ -135,6 +136,24 @@ class ExternalASTSourceWrapper : public 
clang::ExternalSemaSource {
 return m_Source->layoutRecordType(Record, Size, Alignment, FieldOffsets,
   BaseOffsets, VirtualBaseOffsets);
   }
+
+  /// This gets called when Sema is reconciling undefined but used functions.
+  /// For LLDB's use-case, we never provide Clang with function definitions,
+  /// instead we rely on linkage names and symbol resolution to call the
+  /// correct funcitons during JITting. So this implementation clears
+  /// any "undefined" functions Clang found while parsing.
+  ///
+  /// \param[in,out] Undefined A set of used decls for which Clang has not
+  ///  been provided a definition with.
+  ///
+  void ReadUndefinedButUsed(
+  llvm::MapVector &Undefined)
+  override {
+Undefined.remove_if([](auto const &decl_loc_pair) {
+  const clang::NamedDecl *ND = decl_loc_pair.first;
+  return llvm::isa_and_present(ND);
+});
+  }
 };
 
 /// Wraps an ASTConsumer into an SemaConsumer. Doesn't take ownership of the
diff --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index c441153d1efb05..b23e851f547ce9 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1223,6 +1223,8 @@ ClangExpressionParser::ParseInternal(DiagnosticManager 
&diagnostic_manager,
 
 clang::ExternalASTSource *ast_source = decl_map->CreateProxy();
 
+auto *ast_source_wrapper = new ExternalASTSourceWrapper(ast_source);
+
 if (ast_context.getExternalSource()) {
   auto module_wrapper =
   new ExternalASTSourceWrapper(ast_context.getExternalSource());
@@ -1236,6 +1238,7 @@ ClangExpressionParser::ParseInternal(DiagnosticManager 
&diagnostic_manager,
 } else {
   ast_context.setExternalSource(ast_source);
 }
+m_compiler->getSema().addExternalSource(ast_source_wrapper);
 decl_map->InstallASTContext(*m_ast_context);
   }
 
diff --git a/lldb/test/Shell/Expr/TestAnonNamespaceParamFunc.cpp 
b/lldb/test/Shell/Expr/TestAnonNamespaceParamFunc.cpp
new file mode 100644
index 00..750c81c0db6b32
--- /dev/null
+++ b/lldb/test/Shell/Expr/TestAnonNamespaceParamFunc.cpp
@@ -0,0 +1,19 @@
+// TODO: Test that ...
+
+// RUN: %build %s -o %t
+// RUN: %lldb %t -o run -o "expression func(a)" -o exit | FileCheck %s
+
+// CHECK: expression func(a)
+// CHECK: (int) $0 = 15
+
+namespace {
+struct InAnon {};
+} // namespace
+
+int func(InAnon a) { return 15; }
+
+int main() {
+  InAnon a;
+  __builtin_debugtrap();
+  return func(a);
+}

>From 4bdb9e1763d133f1b0712675a4e135cb95e5e50b Mon Sep 17 00:00:00 2001
From: Michael Buch 
Date: Mon, 19 Aug 2024 18:08:34 +0100
Subject: [PATCH 2/3] fixup! adjust comment

---

[Lldb-commits] [lldb] 8056d92 - [lldb][ClangExpressionParser] Implement ExternalSemaSource::ReadUndefinedButUsed (#104817)

2024-08-20 Thread via lldb-commits

Author: Michael Buch
Date: 2024-08-20T18:42:46+01:00
New Revision: 8056d92bc201906edbb27f4efa1cc80a18359880

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

LOG: [lldb][ClangExpressionParser] Implement 
ExternalSemaSource::ReadUndefinedButUsed (#104817)

While parsing an expression, Clang tries to diagnose usage of decls
(with possibly non-external linkage) for which it hasn't been provided
with a definition. This is the case, e.g., for functions with parameters
that live in an anonymous namespace (those will have `UniqueExternal`
linkage, this is computed [here in
computeTypeLinkageInfo](https://github.com/llvm/llvm-project/blob/ea8bb4d633683f5cbfd82491620be3056f347a02/clang/lib/AST/Type.cpp#L4647-L4653)).
Before diagnosing such situations, Clang calls
`ExternalSemaSource::ReadUndefinedButUsed`. The intended use of this API
is to extend the set of "used but not defined" decls with additional
ones that the external source knows about. However, in LLDB's case, we
never provide `FunctionDecl`s with a definition, and instead rely on the
expression parser to resolve those symbols by linkage name. Thus, to
avoid the Clang parser from erroring out in these situations, this patch
implements `ReadUndefinedButUsed` which just removes the "undefined"
non-external `FunctionDecl`s that Clang found.

We also had to add an `ExternalSemaSource` to the `clang::Sema` instance
LLDB creates. We previously didn't have any source on `Sema`. Because we
add the `ExternalASTSourceWrapper` here, that means we'd also
technically be adding the `ClangExpressionDeclMap` as an
`ExternalASTSource` to `Sema`, which is fine because `Sema` will only be
calling into the `ExternalSemaSource` APIs (though nothing currently
strictly enforces this, which is a bit worrying).

Note, the decision for whether to put a function into `UndefinedButUsed`
is done in
[Sema::MarkFunctionReferenced](https://github.com/llvm/llvm-project/blob/ea8bb4d633683f5cbfd82491620be3056f347a02/clang/lib/Sema/SemaExpr.cpp#L18083-L18087).
The `UniqueExternal` linkage computation is done in
[getLVForNamespaceScopeDecl](https://github.com/llvm/llvm-project/blob/ea8bb4d633683f5cbfd82491620be3056f347a02/clang/lib/AST/Decl.cpp#L821-L833).

Fixes https://github.com/llvm/llvm-project/issues/104712

Added: 
lldb/test/Shell/Expr/TestAnonNamespaceParamFunc.cpp

Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h 
b/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
index 44e52e8dd65113..5669c31f1c402e 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTUtils.h
@@ -15,6 +15,7 @@
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/SemaConsumer.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/Support/Casting.h"
 #include 
 
 namespace clang {
@@ -138,6 +139,24 @@ class ExternalASTSourceWrapper : public 
clang::ExternalSemaSource {
 return m_Source->layoutRecordType(Record, Size, Alignment, FieldOffsets,
   BaseOffsets, VirtualBaseOffsets);
   }
+
+  /// This gets called when Sema is reconciling undefined but used decls.
+  /// For LLDB's use-case, we never provide Clang with function definitions,
+  /// instead we rely on linkage names and symbol resolution to call the
+  /// correct funcitons during JITting. So this implementation clears
+  /// any "undefined" FunctionDecls that Clang found while parsing.
+  ///
+  /// \param[in,out] Undefined A set of used decls for which Clang has not
+  ///  been provided a definition with.
+  ///
+  void ReadUndefinedButUsed(
+  llvm::MapVector &Undefined)
+  override {
+Undefined.remove_if([](auto const &decl_loc_pair) {
+  const clang::NamedDecl *ND = decl_loc_pair.first;
+  return llvm::isa_and_present(ND);
+});
+  }
 };
 
 /// Wraps an ASTConsumer into an SemaConsumer. Doesn't take ownership of the

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
index d37787ebae26c3..38fe9fa10493fa 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -1223,6 +1223,8 @@ ClangExpressionParser::ParseInternal(DiagnosticManager 
&diagnostic_manager,
 
 clang::ExternalASTSource *ast_source = decl_map->CreateProxy();
 
+auto *ast_source_wrapper = new ExternalASTSourceWrapper(ast_source);
+
 if (ast_context.getExternalSource()) {
   auto *module_wrapper =
   new Extern

[Lldb-commits] [lldb] [lldb][ClangExpressionParser] Implement ExternalSemaSource::ReadUndefinedButUsed (PR #104817)

2024-08-20 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] 3565332 - [lldb] Fix windows debug build after 9d07f43 (#104896)

2024-08-20 Thread via lldb-commits

Author: Med Ismail Bennani
Date: 2024-08-20T10:47:06-07:00
New Revision: 356533246aa33db44c75afb2d3eb6e0e08f0d7a6

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

LOG: [lldb] Fix windows debug build after 9d07f43 (#104896)

This patch tries to fix an issue with the windows debug builds where the
PDB file for python scripted interfaces cannot be opened since its path
length exceed the windows `MAX_PATH` limit:

https://github.com/llvm/llvm-project/pull/101672#issuecomment-2289481324

This patch addresses the issue by building all the interfaces as a
single library plugin that initiliazes each component as part of its
`Initialize` method, instead of building each interface as its own
library plugin.

This keeps the build artifact path length smaller while respecting the
naming convention and without making any exception in the build system.

Fixes #104895.

Signed-off-by: Med Ismail Bennani 

Added: 

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

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

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

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

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

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

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

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

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

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

Modified: 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Removed: 

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/OperatingSystemPythonInterface/CMakeLists.txt

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

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

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPlatformPythonInterface/CMakeLists.txt

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

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

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedProcessPythonInterface/CMakeLists.txt

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

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

lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedThreadPlanPythonInterface/CMakeLists.txt

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

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



diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt 
b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt
index eb22a960b53454..6ba714ed1c263e 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt
@@ -19,8 +19,13 @@ if (LLDB_ENABLE_LIBEDIT)
   list(APPEND LLDB_LIBEDIT_LIBS LibEdit::LibEdit)
 endif()
 
-add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces
+add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces PLUGIN
+  OperatingSystemPythonInterface.cpp
+  ScriptInterpreterPythonInterfaces.cpp
+  ScriptedPlatformPythonInterface.cpp
+  ScriptedProcessPythonInterface.cpp
   ScriptedPythonInterface.cpp
+  ScriptedThreadPlanPythonInterface.cpp
   ScriptedThreadPythonInterface.cpp
 
   LINK_LIBS
@@ -35,8 +40,4 @@ add_lldb_library(lldbPluginScriptInterpreterPythonInterfaces
 Support
   )
 
-add_subdirectory(OperatingSystemPythonInterface)
-add_subdirectory(ScriptedPlatformPythonInterface)
-add_subdirectory(ScriptedProcessPythonInterface)
-add_subdirectory(ScriptedThreadPlanPythonInterface)
 

diff  --git 
a/lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/OperatingSystem

[Lldb-commits] [lldb] [lldb] Fix windows debug build after 9d07f43 (PR #104896)

2024-08-20 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Disable the API test TestCppBitfields on Windows (PR #105037)

2024-08-20 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][test] Change unsupported cat -e to cat -v to work with lit internal shell (PR #104878)

2024-08-20 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

@DavidSpickett nailed it. 

PS: I'm around but I've been busy with other stuff. If people start to think 
I'm on vacation I really gotta step it up again :D 

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Alex Langford via lldb-commits


@@ -17,6 +17,7 @@
 #include "lldb/lldb-private-forward.h"
 #include "lldb/lldb-public.h"
 
+#include <_types/_uint16_t.h>

bulbazord wrote:

Is this header portable? If you want access to `uint16_t` I'd recommend 
including `cinttypes` instead.

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Alex Langford via lldb-commits


@@ -278,6 +278,29 @@ class CommandObjectFrameSelect : public 
CommandObjectParsed {
   if (frame_idx == UINT32_MAX)
 frame_idx = 0;
 
+  // If moving up/down by one, skip over hidden frames.
+  if (*m_options.relative_frame_offset == 1 ||
+  *m_options.relative_frame_offset == -1) {
+uint32_t candidate_idx = frame_idx;
+for (unsigned num_try = 0; num_try < 12; ++num_try) {

bulbazord wrote:

What does `12` mean here?

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Alex Langford via lldb-commits


@@ -40,8 +41,49 @@ static ConstString g_coro_frame = 
ConstString("__coro_frame");
 
 char CPPLanguageRuntime::ID = 0;
 
+/// A frame recognizer that is installed to hide libc++ implementation
+/// details from the backtrace.
+class LibCXXFrameRecognizer : public StackFrameRecognizer {
+  RegularExpression m_hidden_function_regex;
+  RecognizedStackFrameSP m_hidden_frame;
+
+  struct LibCXXHiddenFrame : public RecognizedStackFrame {
+bool ShouldHide() override { return true; }
+  };
+
+public:
+  LibCXXFrameRecognizer()
+  : m_hidden_function_regex(
+R"(^std::__1::(__function.*::operator\(\)|__invoke))"
+R"((\[.*\])?)"// ABI tag.
+R"(( const)?$)"), // const.
+m_hidden_frame(new LibCXXHiddenFrame()) {}

bulbazord wrote:

suggestion: `make_shared`?

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Alex Langford via lldb-commits


@@ -40,8 +41,49 @@ static ConstString g_coro_frame = 
ConstString("__coro_frame");
 
 char CPPLanguageRuntime::ID = 0;
 
+/// A frame recognizer that is installed to hide libc++ implementation
+/// details from the backtrace.
+class LibCXXFrameRecognizer : public StackFrameRecognizer {
+  RegularExpression m_hidden_function_regex;
+  RecognizedStackFrameSP m_hidden_frame;
+
+  struct LibCXXHiddenFrame : public RecognizedStackFrame {
+bool ShouldHide() override { return true; }
+  };
+
+public:
+  LibCXXFrameRecognizer()
+  : m_hidden_function_regex(
+R"(^std::__1::(__function.*::operator\(\)|__invoke))"
+R"((\[.*\])?)"// ABI tag.
+R"(( const)?$)"), // const.
+m_hidden_frame(new LibCXXHiddenFrame()) {}
+
+  std::string GetName() override { return "libc++ frame recognizer"; }
+
+  lldb::RecognizedStackFrameSP
+  RecognizeFrame(lldb::StackFrameSP frame_sp) override {
+if (!frame_sp)
+  return {};
+auto &sc = frame_sp->GetSymbolContext(lldb::eSymbolContextFunction);
+if (!sc.function)
+  return {};
+
+if (m_hidden_function_regex.Execute(sc.function->GetNameNoArguments()))
+  return m_hidden_frame;
+
+return {};
+  }
+};
+
 CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
-: LanguageRuntime(process) {}
+: LanguageRuntime(process) {
+  if (process)
+process->GetTarget().GetFrameRecognizerManager().AddRecognizer(
+StackFrameRecognizerSP(new LibCXXFrameRecognizer()), {},

bulbazord wrote:

suggestion: `make_shared`?

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


[Lldb-commits] [lldb] [lldb][test] Change unsupported cat -e to cat -v to work with lit internal shell (PR #104878)

2024-08-20 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] 31e55d4 - [lldb] Disable the API test TestCppBitfields on Windows (#105037)

2024-08-20 Thread via lldb-commits

Author: Dmitry Vasilyev
Date: 2024-08-20T22:26:49+04:00
New Revision: 31e55d461693df035049e09cbeeb8886ca2cb6d3

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

LOG: [lldb] Disable the API test TestCppBitfields on Windows (#105037)

This test causes the assert in clang CodeGen and python crashes with the
error code 0x8003. See #105019 for more details. Note the similar
test lldb/test/API/lang/c/bitfields/TestBitfields.py is already disabled
on Windows.

Added: 


Modified: 
lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py

Removed: 




diff  --git a/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py 
b/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
index f796c635895ac1..dba1422a0d52a1 100644
--- a/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
+++ b/lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
@@ -8,6 +8,7 @@
 
 class CppBitfieldsTestCase(TestBase):
 @no_debug_info_test
+@skipIf(oslist=["windows"], 
bugnumber="github.com/llvm/llvm-project/issues/105019")
 def test_bitfields(self):
 self.build()
 lldbutil.run_to_source_breakpoint(



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


[Lldb-commits] [lldb] [lldb] Disable the API test TestCppBitfields on Windows (PR #105037)

2024-08-20 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] WIP: [lldb][test] Workaround older systems that lack gettid (PR #104831)

2024-08-20 Thread Jonas Devlieghere via lldb-commits

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

Thanks!

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


[Lldb-commits] [lldb] [lldb] Adjust the for loop condition to prevent unintended increments in ExpandRLE (NFC) (PR #94844)

2024-08-20 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Adjust the for loop condition to prevent unintended increments in ExpandRLE (NFC) (PR #94844)

2024-08-20 Thread Alex Langford via lldb-commits


@@ -1316,6 +1316,7 @@ std::string GDBRemoteCommunication::ExpandRLE(std::string 
packet) {
 } else {
   decoded.push_back(*c);
 }
+c++;

bulbazord wrote:

Having the `c++` here is equivalent to having it in the "increment" portion of 
the for loop construct, why move it here?


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


[Lldb-commits] [lldb] [lldb] Adjust the for loop condition to prevent unintended increments in ExpandRLE (NFC) (PR #94844)

2024-08-20 Thread Alex Langford via lldb-commits


@@ -1316,6 +1316,7 @@ std::string GDBRemoteCommunication::ExpandRLE(std::string 
packet) {
 } else {

bulbazord wrote:

I can't comment on it for some reason, but above this else is an `else if (*c 
== 0x7d)`. That block also does `*++c`, which will also go out of bounds if 
`std::next(c) == packet.end()`. You need to add a check there too, don't you?

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


[Lldb-commits] [lldb] [lldb][RISCV] Support optionally disabled FPR (PR #104547)

2024-08-20 Thread Francis Visoiu Mistrih via lldb-commits

francisvm wrote:

Why is this riscv64-only?

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Jonas Devlieghere via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere commented:

Mostly nits. 

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Jonas Devlieghere via lldb-commits


@@ -38,13 +42,21 @@ 
ScriptedStackFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame) {
   ValueObjectListSP args =
   m_interpreter->GetRecognizedArguments(m_python_object_sp, frame);
   auto args_synthesized = ValueObjectListSP(new ValueObjectList());
-  for (const auto &o : args->GetObjects()) {
-args_synthesized->Append(ValueObjectRecognizerSynthesizedValue::Create(
-*o, eValueTypeVariableArgument));
-  }
+  if (args)
+for (const auto &o : args->GetObjects())
+  args_synthesized->Append(ValueObjectRecognizerSynthesizedValue::Create(
+  *o, eValueTypeVariableArgument));

JDevlieghere wrote:

```suggestion
  if (args) {
for (const auto &o : args->GetObjects())
  args_synthesized->Append(ValueObjectRecognizerSynthesizedValue::Create(
  *o, eValueTypeVariableArgument));
}
```

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Jonas Devlieghere via lldb-commits


@@ -518,33 +523,33 @@ class StackFrame : public ExecutionContextScope,
   bool HasCachedData() const;
 
 private:
-  // For StackFrame only
+  /// For StackFrame only.

JDevlieghere wrote:

Since you're touching this comment... 

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Jonas Devlieghere via lldb-commits


@@ -123,8 +126,13 @@ class StackFrameRecognizerManager {
   lldb::StackFrameRecognizerSP GetRecognizerForFrame(lldb::StackFrameSP frame);
 
   lldb::RecognizedStackFrameSP RecognizeFrame(lldb::StackFrameSP frame);
+  /// This number changes whenever the list of recognizers has been modified.

JDevlieghere wrote:

Nit:

```
/// Returns a number that changes whenever the list of recognizers has been 
modified.
```

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Jonas Devlieghere via lldb-commits


@@ -518,33 +523,33 @@ class StackFrame : public ExecutionContextScope,
   bool HasCachedData() const;
 
 private:
-  // For StackFrame only
+  /// For StackFrame only.
   lldb::ThreadWP m_thread_wp;
   uint32_t m_frame_index;
   uint32_t m_concrete_frame_index;
   lldb::RegisterContextSP m_reg_context_sp;
   StackID m_id;

JDevlieghere wrote:

```suggestion
  /// For StackFrame only.
  /// @{ 
  lldb::ThreadWP m_thread_wp;
  uint32_t m_frame_index;
  uint32_t m_concrete_frame_index;
  lldb::RegisterContextSP m_reg_context_sp;
  StackID m_id;
  /// @}
```

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Jonas Devlieghere via lldb-commits


@@ -1202,6 +1202,19 @@ bool SBFrame::IsArtificial() const {
   return false;
 }
 
+bool SBFrame::IsHidden() const {
+  LLDB_INSTRUMENT_VA(this);
+
+  std::unique_lock lock;
+  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
+
+  StackFrame *frame = exe_ctx.GetFramePtr();
+  if (frame)
+return frame->IsHidden();

JDevlieghere wrote:

```suggestion
  if (StackFrame *frame = exe_ctx.GetFramePtr())
return frame->IsHidden();
```

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Jonas Devlieghere via lldb-commits


@@ -1208,7 +1208,8 @@ bool SBThread::GetStatus(SBStream &status) const {
   ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
 
   if (exe_ctx.HasThreadScope()) {
-exe_ctx.GetThreadPtr()->GetStatus(strm, 0, 1, 1, true);
+exe_ctx.GetThreadPtr()->GetStatus(strm, 0, 1, 1, true,
+  /*show_hidden*/ true);

JDevlieghere wrote:

Nit: we use `=*/` because that's what the [clang-tidy 
check](https://clang.llvm.org/extra/clang-tidy/checks/bugprone/argument-comment.html)
 understands. 
```suggestion
  /*show_hidden=*/ true);
```

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Jonas Devlieghere via lldb-commits


@@ -17,6 +17,7 @@
 #include "lldb/lldb-private-forward.h"
 #include "lldb/lldb-public.h"
 
+#include <_types/_uint16_t.h>

JDevlieghere wrote:

+1, this looks fishy. `cstdint` or `cinttypes` should do. 

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Jonas Devlieghere via lldb-commits


@@ -40,8 +41,49 @@ static ConstString g_coro_frame = 
ConstString("__coro_frame");
 
 char CPPLanguageRuntime::ID = 0;
 
+/// A frame recognizer that is installed to hide libc++ implementation
+/// details from the backtrace.
+class LibCXXFrameRecognizer : public StackFrameRecognizer {
+  RegularExpression m_hidden_function_regex;
+  RecognizedStackFrameSP m_hidden_frame;
+
+  struct LibCXXHiddenFrame : public RecognizedStackFrame {
+bool ShouldHide() override { return true; }
+  };
+
+public:
+  LibCXXFrameRecognizer()
+  : m_hidden_function_regex(
+R"(^std::__1::(__function.*::operator\(\)|__invoke))"
+R"((\[.*\])?)"// ABI tag.
+R"(( const)?$)"), // const.
+m_hidden_frame(new LibCXXHiddenFrame()) {}
+
+  std::string GetName() override { return "libc++ frame recognizer"; }
+
+  lldb::RecognizedStackFrameSP
+  RecognizeFrame(lldb::StackFrameSP frame_sp) override {
+if (!frame_sp)
+  return {};
+auto &sc = frame_sp->GetSymbolContext(lldb::eSymbolContextFunction);

JDevlieghere wrote:

`const auto&`? 

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


[Lldb-commits] [lldb] 6558e04 - [lldb][test] Change unsupported cat -e to cat -v to work with lit internal shell (#104878)

2024-08-20 Thread via lldb-commits

Author: Connie Zhu
Date: 2024-08-20T11:54:17-07:00
New Revision: 6558e04f02858bff61c01c9ec0900849fc8532f5

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

LOG: [lldb][test] Change unsupported cat -e to cat -v to work with lit internal 
shell (#104878)

This patch changes the test that uses the `cat -e` option to `cat -v` so
that the test can be run using lit's internal shell. For `cat`, the `-v`
option prints non-printing characters in ^ and M- notation, while the
`-e` option adds `$` to the end of lines in addition to printing
non-printing characters in ^ and M- notation. This is an alternative
patch to https://github.com/llvm/llvm-project/pull/102061, opting to
rewrite the test that uses `cat -e` instead of extending support to the
`-e` option.

Fixes https://github.com/llvm/llvm-project/issues/102377

Added: 


Modified: 
lldb/test/Shell/Driver/TestUseColor.test

Removed: 




diff  --git a/lldb/test/Shell/Driver/TestUseColor.test 
b/lldb/test/Shell/Driver/TestUseColor.test
index 15e5814d8ebadd..dcb9f8c1517306 100644
--- a/lldb/test/Shell/Driver/TestUseColor.test
+++ b/lldb/test/Shell/Driver/TestUseColor.test
@@ -1,7 +1,7 @@
 UNSUPPORTED: system-windows
 
 RUN: not %lldb -b -o 'settings set use-color true' -o 'settings show 
use-color' -o 'bogus' > %t 2>&1
-RUN: cat -e %t | FileCheck %s --check-prefix COLOR
+RUN: cat -v %t | FileCheck %s --check-prefix COLOR
 COLOR: use-color (boolean) = true
 # The [[ confuses FileCheck so regex match it.
 COLOR: {{.+}}0;1;31merror: {{.+}}0m'bogus' is not a valid command



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


[Lldb-commits] [lldb] [lldb][test] Change unsupported cat -e to cat -v to work with lit internal shell (PR #104878)

2024-08-20 Thread Paul Kirth via lldb-commits

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


[Lldb-commits] [lldb] [lldb-dap] Enabling instruction breakpoint support to lldb-dap. (PR #105278)

2024-08-20 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
31e55d461693df035049e09cbeeb8886ca2cb6d3...7e221825b8537f69e19cf366c446d9a09a4768fe
 
lldb/test/API/tools/lldb-dap/instruction-breakpoint/TestDAP_instruction_breakpoint.py
 lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
``





View the diff from darker here.


``diff
--- 
test/API/tools/lldb-dap/instruction-breakpoint/TestDAP_instruction_breakpoint.py
2024-08-20 19:21:12.00 +
+++ 
test/API/tools/lldb-dap/instruction-breakpoint/TestDAP_instruction_breakpoint.py
2024-08-20 19:29:09.956487 +
@@ -7,16 +7,16 @@
 import os
 import lldb
 
 
 class TestDAP_InstructionBreakpointTestCase(lldbdap_testcase.DAPTestCaseBase):
+NO_DEBUG_INFO_TESTCASE = True
 
-NO_DEBUG_INFO_TESTCASE = True
 def setUp(self):
 lldbdap_testcase.DAPTestCaseBase.setUp(self)
 
-self.main_basename = 'main-copy.cpp'
+self.main_basename = "main-copy.cpp"
 self.main_path = 
os.path.realpath(self.getBuildArtifact(self.main_basename))
 
 def test_instruction_breakpoint(self):
 self.build()
 self.instruction_breakpoint_test()
@@ -24,53 +24,77 @@
 def instruction_breakpoint_test(self):
 """Sample test to ensure SBFrame::Disassemble produces SOME output"""
 # Create a target by the debugger.
 target = self.createTestTarget()
 
-#build target and create DAP
-#self.build_and_create_debug_adaptor()
+# build target and create DAP
+# self.build_and_create_debug_adaptor()
 
-main_line = line_number('main.cpp', 'breakpoint 1')
+main_line = line_number("main.cpp", "breakpoint 1")
 
 program = self.getBuildArtifact("a.out")
 self.build_and_launch(program)
 
 # Set source breakpoint 1
 response = self.dap_server.request_setBreakpoints(self.main_path, 
[main_line])
-breakpoints = response['body']['breakpoints']
+breakpoints = response["body"]["breakpoints"]
 self.assertEquals(len(breakpoints), 1)
 breakpoint = breakpoints[0]
-self.assertEqual(breakpoint['line'], main_line, "incorrect breakpoint 
source line")
-self.assertTrue(breakpoint['verified'], "breakpoint is not verified")
-self.assertEqual(self.main_basename, breakpoint['source']['name'], 
"incorrect source name")
-self.assertEqual(self.main_path, breakpoint['source']['path'], 
"incorrect source file path")
-other_breakpoint_id = breakpoint['id']
+self.assertEqual(
+breakpoint["line"], main_line, "incorrect breakpoint source line"
+)
+self.assertTrue(breakpoint["verified"], "breakpoint is not verified")
+self.assertEqual(
+self.main_basename, breakpoint["source"]["name"], "incorrect 
source name"
+)
+self.assertEqual(
+self.main_path, breakpoint["source"]["path"], "incorrect source 
file path"
+)
+other_breakpoint_id = breakpoint["id"]
 
 # Continue and then verifiy the breakpoint
 self.dap_server.request_continue()
 self.verify_breakpoint_hit([other_breakpoint_id])
 
 # now we check the stack trace making sure that we got mapped source 
paths
-frames = self.dap_server.request_stackTrace()['body']['stackFrames']
+frames = self.dap_server.request_stackTrace()["body"]["stackFrames"]
 intstructionPointerReference = []
 setIntstructionBreakpoints = []
-
intstructionPointerReference.append(frames[0]['instructionPointerReference'])
-self.assertEqual(frames[0]['source']['name'], self.main_basename, 
"incorrect source name")
-self.assertEqual(frames[0]['source']['path'], self.main_path, 
"incorrect source file path")
+
intstructionPointerReference.append(frames[0]["instructionPointerReference"])
+self.assertEqual(
+frames[0]["source"]["name"], self.main_basename, "incorrect source 
name"
+)
+self.assertEqual(
+frames[0]["source"]["path"], self.main_path, "incorrect source 
file path"
+)
 
 # Check disassembly view
 instruction = self.disassemble(frameIndex=0)
-self.assertEqual(instruction["address"], 
intstructionPointerReference[0], "current breakpoint reference is not in the 
disaasembly view")
+self.assertEqual(
+instruction["address"],
+intstructionPointerReference[0],
+"current breakpoint reference is not in the disaasembly view",
+)
 
 # Get next instruction address to set instruction breakpoint
 disassembled_instruction_list = 
self.dap_server.disassembled_instructions
 instruction_addr_list = list(disassembled_instruction_list.keys())
 index = instruction

[Lldb-commits] [lldb] [lldb-dap] Enabling instruction breakpoint support to lldb-dap. (PR #105278)

2024-08-20 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 31e55d461693df035049e09cbeeb8886ca2cb6d3 
7e221825b8537f69e19cf366c446d9a09a4768fe --extensions cpp,h -- 
lldb/test/API/tools/lldb-dap/instruction-breakpoint/main.cpp 
lldb/tools/lldb-dap/InstructionBreakpoint.cpp 
lldb/tools/lldb-dap/InstructionBreakpoint.h lldb/tools/lldb-dap/DAP.h 
lldb/tools/lldb-dap/DAPForward.h lldb/tools/lldb-dap/JSONUtils.cpp 
lldb/tools/lldb-dap/JSONUtils.h lldb/tools/lldb-dap/lldb-dap.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/test/API/tools/lldb-dap/instruction-breakpoint/main.cpp 
b/lldb/test/API/tools/lldb-dap/instruction-breakpoint/main.cpp
index c4b72144b7..3c710d6417 100644
--- a/lldb/test/API/tools/lldb-dap/instruction-breakpoint/main.cpp
+++ b/lldb/test/API/tools/lldb-dap/instruction-breakpoint/main.cpp
@@ -3,13 +3,13 @@
 
 int function(int x) {
 
-  if (x == 0)// breakpoint 1
+  if (x == 0) // breakpoint 1
 return x;
 
   if ((x % 2) != 0)
 return x;
   else
-return function(x-1) + x;
+return function(x - 1) + x;
 }
 
 int main(int argc, char const *argv[]) {

``




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


[Lldb-commits] [lldb] [lldb-dap] Enabling instruction breakpoint support to lldb-dap. (PR #105278)

2024-08-20 Thread Santhosh Kumar Ellendula via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Adrian Prantl via lldb-commits


@@ -17,6 +17,7 @@
 #include "lldb/lldb-private-forward.h"
 #include "lldb/lldb-public.h"
 
+#include <_types/_uint16_t.h>

adrian-prantl wrote:

That was clang-format.

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Adrian Prantl via lldb-commits


@@ -1208,7 +1208,8 @@ bool SBThread::GetStatus(SBStream &status) const {
   ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
 
   if (exe_ctx.HasThreadScope()) {
-exe_ctx.GetThreadPtr()->GetStatus(strm, 0, 1, 1, true);
+exe_ctx.GetThreadPtr()->GetStatus(strm, 0, 1, 1, true,
+  /*show_hidden*/ true);

adrian-prantl wrote:

TIL!

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Adrian Prantl via lldb-commits


@@ -278,6 +278,29 @@ class CommandObjectFrameSelect : public 
CommandObjectParsed {
   if (frame_idx == UINT32_MAX)
 frame_idx = 0;
 
+  // If moving up/down by one, skip over hidden frames.
+  if (*m_options.relative_frame_offset == 1 ||
+  *m_options.relative_frame_offset == -1) {
+uint32_t candidate_idx = frame_idx;
+for (unsigned num_try = 0; num_try < 12; ++num_try) {

adrian-prantl wrote:

A randomly chosen max. number of tries to avoid infinite loops.

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Adrian Prantl via lldb-commits


@@ -40,8 +41,49 @@ static ConstString g_coro_frame = 
ConstString("__coro_frame");
 
 char CPPLanguageRuntime::ID = 0;
 
+/// A frame recognizer that is installed to hide libc++ implementation
+/// details from the backtrace.
+class LibCXXFrameRecognizer : public StackFrameRecognizer {
+  RegularExpression m_hidden_function_regex;
+  RecognizedStackFrameSP m_hidden_frame;
+
+  struct LibCXXHiddenFrame : public RecognizedStackFrame {
+bool ShouldHide() override { return true; }
+  };
+
+public:
+  LibCXXFrameRecognizer()
+  : m_hidden_function_regex(
+R"(^std::__1::(__function.*::operator\(\)|__invoke))"
+R"((\[.*\])?)"// ABI tag.
+R"(( const)?$)"), // const.
+m_hidden_frame(new LibCXXHiddenFrame()) {}

adrian-prantl wrote:

No, it's a subclass.

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Adrian Prantl via lldb-commits


@@ -40,8 +41,49 @@ static ConstString g_coro_frame = 
ConstString("__coro_frame");
 
 char CPPLanguageRuntime::ID = 0;
 
+/// A frame recognizer that is installed to hide libc++ implementation
+/// details from the backtrace.
+class LibCXXFrameRecognizer : public StackFrameRecognizer {
+  RegularExpression m_hidden_function_regex;
+  RecognizedStackFrameSP m_hidden_frame;
+
+  struct LibCXXHiddenFrame : public RecognizedStackFrame {
+bool ShouldHide() override { return true; }
+  };
+
+public:
+  LibCXXFrameRecognizer()
+  : m_hidden_function_regex(
+R"(^std::__1::(__function.*::operator\(\)|__invoke))"
+R"((\[.*\])?)"// ABI tag.
+R"(( const)?$)"), // const.
+m_hidden_frame(new LibCXXHiddenFrame()) {}
+
+  std::string GetName() override { return "libc++ frame recognizer"; }
+
+  lldb::RecognizedStackFrameSP
+  RecognizeFrame(lldb::StackFrameSP frame_sp) override {
+if (!frame_sp)
+  return {};
+auto &sc = frame_sp->GetSymbolContext(lldb::eSymbolContextFunction);
+if (!sc.function)
+  return {};
+
+if (m_hidden_function_regex.Execute(sc.function->GetNameNoArguments()))
+  return m_hidden_frame;
+
+return {};
+  }
+};
+
 CPPLanguageRuntime::CPPLanguageRuntime(Process *process)
-: LanguageRuntime(process) {}
+: LanguageRuntime(process) {
+  if (process)
+process->GetTarget().GetFrameRecognizerManager().AddRecognizer(
+StackFrameRecognizerSP(new LibCXXFrameRecognizer()), {},

adrian-prantl wrote:

same problem, it's a subclass.

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Adrian Prantl via lldb-commits

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

>From a27308d05fb651a50e92bb9f03a56d8ad424537f Mon Sep 17 00:00:00 2001
From: Adrian Prantl 
Date: Thu, 15 Aug 2024 16:18:33 -0700
Subject: [PATCH] [lldb] Extend frame recognizers to hide frames from
 backtraces

Compilers and language runtimes often use helper functions that are
fundamentally uninteresting when debugging anything but the
compiler/runtime itself. This patch introduces a user-extensible
mechanism that allows for these frames to be hidden from backtraces
and automatically skipped over when navigating the stack with `up` and
`down`, and when stepping out of the current frame.

This does not affect the numbering of frames, so `f ` will still
provide access to the hidden frames. The `bt` output will also print a
hint that frames have been hidden.

My primary motivation for this feature is to hide thunks in the Swift
programming language, but I'm including an example recognizer for
`std::function::operator()` that I wished for myself many times while
debugging LLDB.

The functionality is user-extensible via Python recognizers and
exposed through the SBAPI via SBFrame::IsHidden().

rdar://126629381
---
 lldb/bindings/python/python-wrapper.swig  | 18 +++-
 lldb/include/lldb/API/SBFrame.h   |  4 +
 .../lldb/Interpreter/ScriptInterpreter.h  |  5 ++
 lldb/include/lldb/Target/StackFrame.h | 36 
 lldb/include/lldb/Target/StackFrameList.h |  2 +-
 .../lldb/Target/StackFrameRecognizer.h| 21 +++--
 lldb/include/lldb/Target/Thread.h |  4 +-
 lldb/source/API/SBFrame.cpp   | 15 +++-
 lldb/source/API/SBThread.cpp  |  3 +-
 lldb/source/Commands/CommandCompletions.cpp   |  4 +-
 lldb/source/Commands/CommandObjectFrame.cpp   | 24 ++
 lldb/source/Commands/CommandObjectMemory.cpp  |  3 +-
 lldb/source/Commands/CommandObjectThread.cpp  | 19 -
 lldb/source/Commands/Options.td   |  2 +
 lldb/source/Core/Debugger.cpp |  3 +-
 .../source/Interpreter/CommandInterpreter.cpp |  9 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 44 +-
 .../Python/SWIGPythonBridge.h |  3 +
 .../Python/ScriptInterpreterPython.cpp| 29 +++
 .../Python/ScriptInterpreterPythonImpl.h  |  3 +
 lldb/source/Target/Process.cpp|  7 +-
 lldb/source/Target/StackFrame.cpp | 26 --
 lldb/source/Target/StackFrameList.cpp |  8 +-
 lldb/source/Target/StackFrameRecognizer.cpp   | 29 +--
 lldb/source/Target/Thread.cpp | 12 +--
 lldb/source/Target/ThreadPlanStepOut.cpp  |  2 +-
 .../frame/recognizer/TestFrameRecognizer.py   | 40 +
 .../test/API/commands/frame/recognizer/main.m | 21 ++---
 .../commands/frame/recognizer/recognizer.py   |  5 ++
 .../lang/cpp/std-function-recognizer/Makefile |  4 +
 .../TestStdFunctionRecognizer.py  | 84 +++
 .../lang/cpp/std-function-recognizer/main.cpp | 10 +++
 32 files changed, 424 insertions(+), 75 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-function-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-function-recognizer/main.cpp

diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 8f050643fa68b3..2ce42e3e017d5b 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -813,7 +813,7 @@ PythonObject 
lldb_private::python::SWIGBridge::LLDBSWIGPython_CreateFrameRecogni
 }
 
 PyObject 
*lldb_private::python::SWIGBridge::LLDBSwigPython_GetRecognizedArguments(
-PyObject * implementor, const lldb::StackFrameSP &frame_sp) {
+PyObject *implementor, const lldb::StackFrameSP &frame_sp) {
   static char callee_name[] = "get_recognized_arguments";
 
   PythonObject arg = SWIGBridge::ToSWIGWrapper(frame_sp);
@@ -824,6 +824,22 @@ PyObject 
*lldb_private::python::SWIGBridge::LLDBSwigPython_GetRecognizedArgument
   return result;
 }
 
+bool lldb_private::python::SWIGBridge::LLDBSwigPython_ShouldHide(
+PyObject *implementor, const lldb::StackFrameSP &frame_sp) {
+  static char callee_name[] = "should_hide";
+
+  PythonObject arg = SWIGBridge::ToSWIGWrapper(frame_sp);
+
+  PythonString str(callee_name);
+
+  PyObject *result =
+  PyObject_CallMethodObjArgs(implementor, str.get(), arg.get(), NULL);
+  bool ret_val = result ? PyObject_IsTrue(result) : false;
+  Py_XDECREF(result);
+
+  return result;
+}
+
 void *lldb_private::python::SWIGBridge::LLDBSWIGPython_GetDynamicSetting(
 void *module, const char *setting, const lldb::TargetSP &target_sp) {
   if (!module || !setting)
diff --git a/lldb/include/lldb/API/SBFrame.h b/lldb/include/lldb/API/SBFrame.h
index 821ff3cf7ce519..e0d15c3ecc5b1c 100644
--- a/lldb/include/lldb/API/SBFrame.h
+++ b/lldb/inclu

[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Jonas Devlieghere via lldb-commits

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

LGTM

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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Add selectable memory regions to SBSaveCore (PR #105442)

2024-08-20 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)


Changes

This patch adds the option to specify specific memory ranges to be included in 
a given core file. The current implementation lets user specified ranges either 
be in addition to a certain save style, or independent of them via the newly 
added custom enum.

To achieve being inclusive of save style, I've moved from a std::vector of 
ranges to a RangeDataVector, and to join overlapping ranges to prevent 
duplication of memory ranges in the core file.

As a non function bonus, when SBSavecore was initially created, the header was 
included in the lldb-private interfaces, and I've fixed that and moved it the 
forward declare as an oversight. CC @bulbazord in case we need to 
include that into swift.



---

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


21 Files Affected:

- (modified) lldb/include/lldb/API/SBMemoryRegionInfo.h (+1-1) 
- (modified) lldb/include/lldb/API/SBMemoryRegionInfoList.h (-1) 
- (modified) lldb/include/lldb/API/SBSaveCoreOptions.h (+11) 
- (modified) lldb/include/lldb/Symbol/SaveCoreOptions.h (+10-2) 
- (modified) lldb/include/lldb/Target/Process.h (+2-1) 
- (modified) lldb/include/lldb/Utility/RangeMap.h (+4) 
- (modified) lldb/include/lldb/lldb-enumerations.h (+1) 
- (modified) lldb/include/lldb/lldb-forward.h (+1) 
- (modified) lldb/include/lldb/lldb-private-interfaces.h (-1) 
- (modified) lldb/source/API/SBSaveCoreOptions.cpp (+13) 
- (modified) lldb/source/Commands/CommandObjectProcess.cpp (+1) 
- (modified) lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (+3-1) 
- (modified) lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h (+1) 
- (modified) lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
(+17-11) 
- (modified) lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h 
(+3-2) 
- (modified) lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h (+1) 
- (modified) lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp (+1) 
- (modified) lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h (+1) 
- (modified) lldb/source/Symbol/SaveCoreOptions.cpp (+16-1) 
- (modified) lldb/source/Target/Process.cpp (+34-7) 
- (modified) 
lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
 (+86) 


``diff
diff --git a/lldb/include/lldb/API/SBMemoryRegionInfo.h 
b/lldb/include/lldb/API/SBMemoryRegionInfo.h
index be55de4ead1fa8..f9a5dc993d7cb6 100644
--- a/lldb/include/lldb/API/SBMemoryRegionInfo.h
+++ b/lldb/include/lldb/API/SBMemoryRegionInfo.h
@@ -120,7 +120,7 @@ class LLDB_API SBMemoryRegionInfo {
 private:
   friend class SBProcess;
   friend class SBMemoryRegionInfoList;
-
+  friend class SBSaveCoreOptions;
   friend class lldb_private::ScriptInterpreter;
 
   lldb_private::MemoryRegionInfo &ref();
diff --git a/lldb/include/lldb/API/SBMemoryRegionInfoList.h 
b/lldb/include/lldb/API/SBMemoryRegionInfoList.h
index 1d939dff55faa3..7207171bf6d647 100644
--- a/lldb/include/lldb/API/SBMemoryRegionInfoList.h
+++ b/lldb/include/lldb/API/SBMemoryRegionInfoList.h
@@ -45,7 +45,6 @@ class LLDB_API SBMemoryRegionInfoList {
 
 private:
   friend class SBProcess;
-
   lldb_private::MemoryRegionInfos &ref();
 
   const lldb_private::MemoryRegionInfos &ref() const;
diff --git a/lldb/include/lldb/API/SBSaveCoreOptions.h 
b/lldb/include/lldb/API/SBSaveCoreOptions.h
index ba48ba5eaea5a0..d14ffe023188a2 100644
--- a/lldb/include/lldb/API/SBSaveCoreOptions.h
+++ b/lldb/include/lldb/API/SBSaveCoreOptions.h
@@ -80,6 +80,17 @@ class LLDB_API SBSaveCoreOptions {
   /// \return True if the thread was removed, false if it was not in the list.
   bool RemoveThread(lldb::SBThread thread);
 
+  /// Add a memory region to save in the core file.
+  ///
+  /// \param region The memory region to save.
+  /// \returns An empty SBStatus upon success, or an error if the region is
+  /// invalid.
+  /// \note Ranges that overlapped with be unioned into a single region this
+  /// also supercedes stack minification. Specifying full regions and a
+  /// non-custom core style will include the specified regions and union them
+  /// with all style specific regions.
+  SBError AddMemoryRegionToSave(const SBMemoryRegionInfo ®ion);
+
   /// Reset all options.
   void Clear();
 
diff --git a/lldb/include/lldb/Symbol/SaveCoreOptions.h 
b/lldb/include/lldb/Symbol/SaveCoreOptions.h
index f4fed4676fa4ae..a95686ada96a79 100644
--- a/lldb/include/lldb/Symbol/SaveCoreOptions.h
+++ b/lldb/include/lldb/Symbol/SaveCoreOptions.h
@@ -10,12 +10,15 @@
 #define LLDB_SOURCE_PLUGINS_OBJECTFILE_SaveCoreOPTIONS_H
 
 #include "lldb/Utility/FileSpec.h"
-#include "lldb/lldb-forward.h"
-#include "lldb/lldb-types.h"
+#include "lldb/Utility/RangeMap.h"
+
 
 #include 
 #include 
 #include 
+#include 
+
+using MemoryRanges = lldb_private::RangeVector;
 
 namespace lldb_private {
 
@@ -38,8 +41,12 @@ class SaveCor

[Lldb-commits] [lldb] [LLDB][SBSaveCore] Add selectable memory regions to SBSaveCore (PR #105442)

2024-08-20 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
c4bf949171a72383d5ba4d2b587d4cc496aacebb...001ed7aa004480e052d5aecf29c7ce8132c60d24
 
lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
``





View the diff from darker here.


``diff
--- TestProcessSaveCoreMinidump.py  2024-08-20 21:58:44.00 +
+++ TestProcessSaveCoreMinidump.py  2024-08-20 22:10:20.400779 +
@@ -317,11 +317,10 @@
 self.assertState(process.GetState(), lldb.eStateStopped)
 
 memory_region = lldb.SBMemoryRegionInfo()
 memory_list = process.GetMemoryRegions()
 memory_list.GetMemoryRegionAtIndex(0, memory_region)
-
 
 # This is almost identical to the single thread test case because
 # minidump defaults to stacks only, so we want to see if the
 # default options work as expected.
 options = lldb.SBSaveCoreOptions()
@@ -329,41 +328,44 @@
 options.SetOutputFile(file_spec)
 options.SetPluginName("minidump")
 options.AddMemoryRegionToSave(memory_region)
 options.SetStyle(lldb.eSaveCoreCustom)
 error = process.SaveCore(options)
-print (f"Error: {error.GetCString()}")
+print(f"Error: {error.GetCString()}")
 self.assertTrue(error.Success(), error.GetCString())
 
 core_target = self.dbg.CreateTarget(None)
 core_proc = target.LoadCore(one_region_file)
 core_memory_list = core_proc.GetMemoryRegions()
 # Note because the /proc/pid maps are included on linux, we can't
 # depend on size for validation, so we'll ensure the first region
 # is present and then assert we fail on the second.
 core_memory_region = lldb.SBMemoryRegionInfo()
 core_memory_list.GetMemoryRegionAtIndex(0, core_memory_region)
-self.assertEqual(core_memory_region.GetRegionBase(), 
memory_region.GetRegionBase())
-self.assertEqual(core_memory_region.GetRegionEnd(), 
memory_region.GetRegionEnd())
-
+self.assertEqual(
+core_memory_region.GetRegionBase(), 
memory_region.GetRegionBase()
+)
+self.assertEqual(
+core_memory_region.GetRegionEnd(), memory_region.GetRegionEnd()
+)
+
 region_two = lldb.SBMemoryRegionInfo()
 core_memory_list.GetMemoryRegionAtIndex(1, region_two)
 err = lldb.SBError()
 content = core_proc.ReadMemory(region_two.GetRegionBase(), 1, err)
 self.assertTrue(err.Fail(), "Should fail to read memory")
 
-
 finally:
 self.assertTrue(self.dbg.DeleteTarget(target))
 if os.path.isfile(one_region_file):
 os.unlink(one_region_file)
 
 @skipUnlessArch("x86_64")
 @skipUnlessPlatform(["linux"])
 def test_save_minidump_custom_save_style(self):
-"""Test that verifies a custom and unspecified save style fails for 
-containing no data to save"""
+"""Test that verifies a custom and unspecified save style fails for
+containing no data to save"""
 
 self.build()
 exe = self.getBuildArtifact("a.out")
 custom_file = self.getBuildArtifact("core.custom.dmp")
 try:
@@ -378,11 +380,13 @@
 options.SetPluginName("minidump")
 options.SetStyle(lldb.eSaveCoreCustom)
 
 error = process.SaveCore(options)
 self.assertTrue(error.Fail())
-self.assertEqual(error.GetCString(), "no valid address ranges 
found for core style")
+self.assertEqual(
+error.GetCString(), "no valid address ranges found for core 
style"
+)
 
 finally:
 self.assertTrue(self.dbg.DeleteTarget(target))
 if os.path.isfile(custom_file):
 os.unlink(custom_file)

``




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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Add selectable memory regions to SBSaveCore (PR #105442)

2024-08-20 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff c4bf949171a72383d5ba4d2b587d4cc496aacebb 
001ed7aa004480e052d5aecf29c7ce8132c60d24 --extensions h,cpp -- 
lldb/include/lldb/API/SBMemoryRegionInfo.h 
lldb/include/lldb/API/SBMemoryRegionInfoList.h 
lldb/include/lldb/API/SBSaveCoreOptions.h 
lldb/include/lldb/Symbol/SaveCoreOptions.h lldb/include/lldb/Target/Process.h 
lldb/include/lldb/Utility/RangeMap.h lldb/include/lldb/lldb-enumerations.h 
lldb/include/lldb/lldb-forward.h lldb/include/lldb/lldb-private-interfaces.h 
lldb/source/API/SBSaveCoreOptions.cpp 
lldb/source/Commands/CommandObjectProcess.cpp 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h 
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h 
lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h 
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp 
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h 
lldb/source/Symbol/SaveCoreOptions.cpp lldb/source/Target/Process.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/include/lldb/Symbol/SaveCoreOptions.h 
b/lldb/include/lldb/Symbol/SaveCoreOptions.h
index a95686ada9..d90d080260 100644
--- a/lldb/include/lldb/Symbol/SaveCoreOptions.h
+++ b/lldb/include/lldb/Symbol/SaveCoreOptions.h
@@ -12,11 +12,10 @@
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/RangeMap.h"
 
-
 #include 
+#include 
 #include 
 #include 
-#include 
 
 using MemoryRanges = lldb_private::RangeVector;
 
@@ -44,7 +43,7 @@ public:
   bool HasSpecifiedThreads() const;
 
   Status EnsureValidConfiguration(lldb::ProcessSP process_sp) const;
-  const MemoryRanges& GetCoreFileMemoryRanges() const;
+  const MemoryRanges &GetCoreFileMemoryRanges() const;
 
   void AddMemoryRegionToSave(const lldb_private::MemoryRegionInfo ®ion);
 
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 73228f13dc..a192065c4d 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -35,6 +35,7 @@
 #include "lldb/Host/ProcessLaunchInfo.h"
 #include "lldb/Host/ProcessRunLock.h"
 #include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Symbol/SaveCoreOptions.h"
 #include "lldb/Target/ExecutionContextScope.h"
 #include "lldb/Target/InstrumentationRuntime.h"
 #include "lldb/Target/Memory.h"
@@ -43,7 +44,6 @@
 #include "lldb/Target/ThreadList.h"
 #include "lldb/Target/ThreadPlanStack.h"
 #include "lldb/Target/Trace.h"
-#include "lldb/Symbol/SaveCoreOptions.h"
 #include "lldb/Utility/AddressableBits.h"
 #include "lldb/Utility/ArchSpec.h"
 #include "lldb/Utility/Broadcaster.h"
@@ -734,7 +734,9 @@ public:
 }
   };
 
-  using CoreFileMemoryRanges = lldb_private::RangeDataVector;
+  using CoreFileMemoryRanges =
+  lldb_private::RangeDataVector;
 
   /// Helper function for Process::SaveCore(...) that calculates the address
   /// ranges that should be saved. This allows all core file plug-ins to save
diff --git a/lldb/include/lldb/Utility/RangeMap.h 
b/lldb/include/lldb/Utility/RangeMap.h
index dacc638c19..216863ac96 100644
--- a/lldb/include/lldb/Utility/RangeMap.h
+++ b/lldb/include/lldb/Utility/RangeMap.h
@@ -449,8 +449,8 @@ public:
   ~RangeDataVector() = default;
 
   void Append(const Entry &entry) { m_entries.emplace_back(entry); }
-  
-  void Append(const B&& b, const S&& s, const T&& t) {
+
+  void Append(const B &&b, const S &&s, const T &&t) {
 m_entries.emplace_back(Entry(b, s, t));
   }
 
diff --git a/lldb/source/API/SBSaveCoreOptions.cpp 
b/lldb/source/API/SBSaveCoreOptions.cpp
index 03d237d349..b9853f85cf 100644
--- a/lldb/source/API/SBSaveCoreOptions.cpp
+++ b/lldb/source/API/SBSaveCoreOptions.cpp
@@ -93,10 +93,10 @@ bool SBSaveCoreOptions::RemoveThread(lldb::SBThread thread) 
{
   return m_opaque_up->RemoveThread(thread.GetSP());
 }
 
-
-lldb::SBError SBSaveCoreOptions::AddMemoryRegionToSave(const 
SBMemoryRegionInfo ®ion) {
+lldb::SBError
+SBSaveCoreOptions::AddMemoryRegionToSave(const SBMemoryRegionInfo ®ion) {
   LLDB_INSTRUMENT_VA(this, region);
-  // Currently add memory region can't fail, so we always return a success 
+  // Currently add memory region can't fail, so we always return a success
   // SBerror, but because these API's live forever, this is the most future
   // proof thing to do.
   m_opaque_up->AddMemoryRegionToSave(region.ref());
diff --git a/lldb/source/Commands/CommandObjectProcess.cpp 
b/lldb/source/Commands/CommandObjectProcess.cpp
index 398eb574f7..1a5ce7de8c 100644
--- a/lldb/source/Commands/CommandObjectProcess.cpp
+++ b/lldb/source/Commands/CommandObjectProcess.cpp
@@ -25,13 +25,13 @@
 #include "lldb/Interpreter/OptionArgParser.h"
 #include "lldb/Interpreter/OptionGroupPythonC

[Lldb-commits] [lldb] WIP: [lldb][test] Workaround older systems that lack gettid (PR #104831)

2024-08-20 Thread Will Hawkins via lldb-commits

https://github.com/hawkinsw updated 
https://github.com/llvm/llvm-project/pull/104831

>From 93949029c808e2e5991df2f3c498dcd008367c34 Mon Sep 17 00:00:00 2001
From: Will Hawkins 
Date: Mon, 19 Aug 2024 14:43:45 -0400
Subject: [PATCH] [lldb][test] Workaround older systems that lack gettid

Older glibc versions do not have `gettid`. Provide our own `gettid` in these
cases.

Fixes a build failure caused by #104109.
---
 lldb/unittests/Process/elf-core/CMakeLists.txt| 11 +++
 lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp |  5 +
 2 files changed, 16 insertions(+)

diff --git a/lldb/unittests/Process/elf-core/CMakeLists.txt 
b/lldb/unittests/Process/elf-core/CMakeLists.txt
index b852a3ffb863c1..68ab6e0683c182 100644
--- a/lldb/unittests/Process/elf-core/CMakeLists.txt
+++ b/lldb/unittests/Process/elf-core/CMakeLists.txt
@@ -1,3 +1,6 @@
+include(CheckSymbolExists)
+include(CMakePushCheckState)
+
 add_lldb_unittest(ProcessElfCoreTests
   ThreadElfCoreTest.cpp
 
@@ -13,3 +16,11 @@ add_lldb_unittest(ProcessElfCoreTests
   LINK_COMPONENTS
 Support
   )
+
+cmake_push_check_state()
+set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
+check_symbol_exists(gettid "unistd.h" HAVE_GETTID)
+if(HAVE_GETTID)
+  target_compile_definitions(ProcessElfCoreTests PRIVATE HAVE_GETTID)
+endif()
+cmake_pop_check_state()
diff --git a/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp 
b/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp
index ce146f62b0d826..c9879f5d94d538 100644
--- a/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp
+++ b/lldb/unittests/Process/elf-core/ThreadElfCoreTest.cpp
@@ -23,6 +23,11 @@
 #include 
 #include 
 
+#ifndef HAVE_GETTID
+#include 
+pid_t gettid() { return ((pid_t)syscall(SYS_gettid)); }
+#endif
+
 using namespace lldb_private;
 
 namespace {

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


[Lldb-commits] [lldb] WIP: [lldb][test] Workaround older systems that lack gettid (PR #104831)

2024-08-20 Thread Will Hawkins via lldb-commits

hawkinsw wrote:

@petrhosek Just requesting another review because of the change that I made 
after your feedback! I'm just being cautious. Sorry to bother you!

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


[Lldb-commits] [lldb] 8d712b4 - [lldb][test] XFAIL TestAnonNamespaceParamFunc.cpp on Windows

2024-08-20 Thread Michael Buch via lldb-commits

Author: Michael Buch
Date: 2024-08-20T23:30:08+01:00
New Revision: 8d712b4e3f14fe0102a5065cbd5b758dc997b529

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

LOG: [lldb][test] XFAIL TestAnonNamespaceParamFunc.cpp on Windows

This recently added test is failing on Windows with:
```
c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\lldb.exe --no-lldbinit 
-S 
C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/tools/lldb\test\Shell\lit-lldb-init-quiet
 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\Expr\Output\TestAnonNamespaceParamFunc.cpp.tmp
 -o run -o "expression func(a)" -o exit | 
c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\filecheck.exe 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\Shell\Expr\TestAnonNamespaceParamFunc.cpp
executed command: 
'c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\lldb.exe' 
--no-lldbinit -S 
'C:/Users/tcwg/llvm-worker/lldb-aarch64-windows/build/tools/lldb\test\Shell\lit-lldb-init-quiet'
 
'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\build\tools\lldb\test\Shell\Expr\Output\TestAnonNamespaceParamFunc.cpp.tmp'
 -o run -o 'expression func(a)' -o exit
.---command stderr
| TestAnonNamespaceParamFunc.cpp.tmp :: Class 'tagARRAYDESC' has a member 
'tdescElem' of type 'tagTYPEDESC' which does not have a complete 
definition.error: TestAnonNamespaceParamFunc.cpp.tmp :: Class 'tagARRAYDESC' 
has a member 'tdescElem' of type 'tagTYPEDESC' which does not have a complete 
definition.
| (lldb) TestAnonNamespaceParamFunc.cpp.tmp :: Class 'std::partial_ordering' 
has a member 'less' of type 'std::partial_ordering' which does not have a 
complete definition.error: TestAnonNamespaceParamFunc.cpp.tmp :: Class 
'std::partial_ordering' has a member 'less' of type 'std::partial_ordering' 
which does not have a complete definition.
| (lldb) TestAnonNamespaceParamFunc.cpp.tmp :: Class 'std::strong_ordering' has 
a member 'less' of type 'std::strong_ordering' which does not have a complete 
definition.error: TestAnonNamespaceParamFunc.cpp.tmp :: Class 
'std::strong_ordering' has a member 'less' of type 'std::strong_ordering' which 
does not have a complete definition.
| (lldb) TestAnonNamespaceParamFunc.cpp.tmp :: Class 'std::weak_ordering' has a 
member 'less' of type 'std::weak_ordering' which does not have a complete 
definition.error: TestAnonNamespaceParamFunc.cpp.tmp :: Class 
'std::weak_ordering' has a member 'less' of type 'std::weak_ordering' which 
does not have a complete definition.
| (lldb) error: Couldn't look up symbols:
|   int func(struct `anonymous namespace'::InAnon)
| Hint: The expression tried to call a function that is not present in the 
target, perhaps because it was optimized out by the compiler.
`-
executed command: 
'c:\users\tcwg\llvm-worker\lldb-aarch64-windows\build\bin\filecheck.exe' 
'C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\Shell\Expr\TestAnonNamespaceParamFunc.cpp'
.---command stderr
| 
C:\Users\tcwg\llvm-worker\lldb-aarch64-windows\llvm-project\lldb\test\Shell\Expr\TestAnonNamespaceParamFunc.cpp:10:11:
 error: CHECK: expected string not found in input
| // CHECK: (int) $0 = 15
|   ^
| :16:26: note: scanning from here
| (lldb) expression func(a)
|  ^
```

So the function is still not callable. But AFAICT, this is not a
regression, since this function wasn't callable prior to the patch
anyway. I currently do not have a Windows setup to test this on,
so XFAIL for now.

Added: 


Modified: 
lldb/test/Shell/Expr/TestAnonNamespaceParamFunc.cpp

Removed: 




diff  --git a/lldb/test/Shell/Expr/TestAnonNamespaceParamFunc.cpp 
b/lldb/test/Shell/Expr/TestAnonNamespaceParamFunc.cpp
index 1882be1b31a899..3d7b193dc6aaca 100644
--- a/lldb/test/Shell/Expr/TestAnonNamespaceParamFunc.cpp
+++ b/lldb/test/Shell/Expr/TestAnonNamespaceParamFunc.cpp
@@ -3,6 +3,8 @@
 // linkage. In this case, a function whose argument
 // is not legally usable outside this TU.
 
+// XFAIL: system-windows
+
 // RUN: %build %s -o %t
 // RUN: %lldb %t -o run -o "expression func(a)" -o exit | FileCheck %s
 



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


[Lldb-commits] [lldb] WIP: [lldb][test] Workaround older systems that lack gettid (PR #104831)

2024-08-20 Thread Paul Kirth via lldb-commits

ilovepi wrote:

@hawkinsw I think you're fine to land this. From what I can tell you've 
addressed @petrhosek's comments. I work on the same team as him, so we'd like 
to see our CI go green ASAP.

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


[Lldb-commits] [lldb] [lldb] Extend frame recognizers to hide frames from backtraces (PR #104523)

2024-08-20 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] f01f80c - [lldb] Extend frame recognizers to hide frames from backtraces (#104523)

2024-08-20 Thread via lldb-commits

Author: Adrian Prantl
Date: 2024-08-20T16:01:22-07:00
New Revision: f01f80ce6ca7640bb0e267b84b1ed0e89b57e2d9

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

LOG: [lldb] Extend frame recognizers to hide frames from backtraces (#104523)

Compilers and language runtimes often use helper functions that are
fundamentally uninteresting when debugging anything but the
compiler/runtime itself. This patch introduces a user-extensible
mechanism that allows for these frames to be hidden from backtraces and
automatically skipped over when navigating the stack with `up` and
`down`.

This does not affect the numbering of frames, so `f ` will still
provide access to the hidden frames. The `bt` output will also print a
hint that frames have been hidden.

My primary motivation for this feature is to hide thunks in the Swift
programming language, but I'm including an example recognizer for
`std::function::operator()` that I wished for myself many times while
debugging LLDB.

rdar://126629381


Example output. (Yes, my proof-of-concept recognizer could hide even
more frames if we had a method that returned the function name without
the return type or I used something that isn't based off regex, but it's
really only meant as an example).

before:
```
(lldb) thread backtrace --filtered=false
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
  * frame #0: 0x00011f04 a.out`foo(x=1, y=1) at main.cpp:4:10
frame #1: 0x00013a00 a.out`decltype(std::declval()(std::declval(), std::declval())) 
std::__1::__invoke[abi:se20](__f=0x00016fdff280, __args=0x00016fdff224, 
__args=0x00016fdff220) at invoke.h:149:25
frame #2: 0x0001399c a.out`int 
std::__1::__invoke_void_return_wrapper::__call[abi:se20](__args=0x00016fdff280, __args=0x00016fdff224, 
__args=0x00016fdff220) at invoke.h:216:12
frame #3: 0x00013968 a.out`std::__1::__function::__alloc_func, int (int, 
int)>::operator()[abi:se20](this=0x00016fdff280, 
__arg=0x00016fdff224, __arg=0x00016fdff220) at function.h:171:12
frame #4: 0x000126bc a.out`std::__1::__function::__func, int (int, 
int)>::operator()(this=0x00016fdff278, __arg=0x00016fdff224, 
__arg=0x00016fdff220) at function.h:313:10
frame #5: 0x00013c38 a.out`std::__1::__function::__value_func::operator()[abi:se20](this=0x00016fdff278, 
__args=0x00016fdff224, __args=0x00016fdff220) const at function.h:430:12
frame #6: 0x00012038 a.out`std::__1::function::operator()(this= Function = foo(int, int) , __arg=1, __arg=1) const at 
function.h:989:10
frame #7: 0x00011f64 a.out`main(argc=1, argv=0x00016fdff4f8) at 
main.cpp:9:10
frame #8: 0x000183cdf154 dyld`start + 2476
(lldb) 
```

after

```
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
  * frame #0: 0x00011f04 a.out`foo(x=1, y=1) at main.cpp:4:10
frame #1: 0x00013a00 a.out`decltype(std::declval()(std::declval(), std::declval())) 
std::__1::__invoke[abi:se20](__f=0x00016fdff280, __args=0x00016fdff224, 
__args=0x00016fdff220) at invoke.h:149:25
frame #2: 0x0001399c a.out`int 
std::__1::__invoke_void_return_wrapper::__call[abi:se20](__args=0x00016fdff280, __args=0x00016fdff224, 
__args=0x00016fdff220) at invoke.h:216:12
frame #6: 0x00012038 a.out`std::__1::function::operator()(this= Function = foo(int, int) , __arg=1, __arg=1) const at 
function.h:989:10
frame #7: 0x00011f64 a.out`main(argc=1, argv=0x00016fdff4f8) at 
main.cpp:9:10
frame #8: 0x000183cdf154 dyld`start + 2476
Note: Some frames were hidden by frame recognizers
```

Added: 
lldb/test/API/lang/cpp/std-function-recognizer/Makefile
lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py
lldb/test/API/lang/cpp/std-function-recognizer/main.cpp

Modified: 
lldb/bindings/python/python-wrapper.swig
lldb/include/lldb/API/SBFrame.h
lldb/include/lldb/Interpreter/ScriptInterpreter.h
lldb/include/lldb/Target/StackFrame.h
lldb/include/lldb/Target/StackFrameList.h
lldb/include/lldb/Target/StackFrameRecognizer.h
lldb/include/lldb/Target/Thread.h
lldb/source/API/SBFrame.cpp
lldb/source/API/SBThread.cpp
lldb/source/Commands/CommandCompletions.cpp
lldb/source/Commands/CommandObjectFrame.cpp
lldb/source/Commands/CommandObjectMemory.cpp
lldb/source/Commands/CommandObjectThread.cpp
lldb/source/Commands/Options.td
lldb/source/Core/Debugger.cpp
lldb/source/Interpreter/CommandInterpreter.cpp
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h
lldb/source/Plugins/ScriptInterpreter/Python/Sc

[Lldb-commits] [lldb] [lldb-dap] Fix disassembled ranges for `disassemble` request (PR #105446)

2024-08-20 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang created 
https://github.com/llvm/llvm-project/pull/105446

This is a first draft PR which fixes #103021

The main issue was that the `instructionOffset` was handled as a byte offset 
and not as an instruction offset.

This commit also incorporates previous feedback from 
https://reviews.llvm.org/D140358: With this change, we are using symbols and 
DWARF debug information to find function boundaries and correctly start 
disassembling at this address.

TODO:
* Update test case
* Check if we can also support disassembling across functions



>From b809f570dd8055e5b899c337ec9ff5110ab94c6e Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Mon, 19 Aug 2024 15:15:22 +
Subject: [PATCH] [lldb-dap] Fix disassembled ranges for `disassemble` request

TODO:
* Update test case
* Check if we can also support disassembling across functions

Incorporated feedback from https://reviews.llvm.org/D140358
---
 .../test/tools/lldb-dap/dap_server.py |  4 +-
 .../disassemble/TestDAP_disassemble.py|  8 +++
 lldb/tools/lldb-dap/lldb-dap.cpp  | 68 +--
 3 files changed, 71 insertions(+), 9 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
index a324af57b61df3..75731ebfde6723 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py
@@ -674,11 +674,11 @@ def request_disconnect(self, terminateDebuggee=None):
 return self.send_recv(command_dict)
 
 def request_disassemble(
-self, memoryReference, offset=-50, instructionCount=200, 
resolveSymbols=True
+self, memoryReference, instructionOffset=0, instructionCount=10, 
resolveSymbols=True
 ):
 args_dict = {
 "memoryReference": memoryReference,
-"offset": offset,
+"instructionOffset": instructionOffset,
 "instructionCount": instructionCount,
 "resolveSymbols": resolveSymbols,
 }
diff --git a/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py 
b/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
index 9e8ef5b289f2e8..ab72eb2d13d729 100644
--- a/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
+++ b/lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
@@ -29,6 +29,14 @@ def test_disassemble(self):
 )
 self.continue_to_next_stop()
 
+stackFrames = self.get_stackFrames(
+threadId=threadId, startFrame=frameIndex, levels=1
+)
+self.assertIsNotNone(stackFrames)
+
+# XXX finish updating test case
+memoryReference = stackFrames[0]["instructionPointerReference"]
+
 pc_assembly = self.disassemble(frameIndex=0)
 self.assertIn("location", pc_assembly, "Source location missing.")
 self.assertIn("instruction", pc_assembly, "Assembly instruction 
missing.")
diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index ea84f31aec3a6c..5d9d28b59ea805 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -3910,8 +3910,8 @@ void request_disassemble(const llvm::json::Object 
&request) {
 return;
   }
 
-  addr_ptr += GetSigned(arguments, "instructionOffset", 0);
-  lldb::SBAddress addr(addr_ptr, g_dap.target);
+  addr_ptr += GetSigned(arguments, "offset", 0);
+  lldb::SBAddress addr = g_dap.target.ResolveLoadAddress(addr_ptr);
   if (!addr.IsValid()) {
 response["success"] = false;
 response["message"] = "Memory reference not found in the current binary.";
@@ -3919,9 +3919,27 @@ void request_disassemble(const llvm::json::Object 
&request) {
 return;
   }
 
-  const auto inst_count = GetUnsigned(arguments, "instructionCount", 0);
-  lldb::SBInstructionList insts =
-  g_dap.target.ReadInstructions(addr, inst_count);
+  int64_t inst_offset = GetSigned(arguments, "instructionOffset", 0);
+  const int64_t inst_count = GetSigned(arguments, "instructionCount", 0);
+  if (inst_count < 0) {
+response["success"] = false;
+response["message"] = "Negative instruction count.";
+g_dap.SendJSON(llvm::json::Value(std::move(response)));
+return;
+  }
+
+  lldb::SBInstructionList insts;
+  if (lldb::SBFunction func = addr.GetFunction()) {
+// First try to identify the function boundaries through debug information
+insts = func.GetInstructions(g_dap.target);
+  } else if (lldb::SBSymbol sym = addr.GetSymbol()) {
+// Try to identify the function boundaries through the symbol table
+insts = sym.GetInstructions(g_dap.target);
+  } else {
+// We could not identify the function. Just disassemble starting from the
+// provided address.
+insts = g_dap.target.ReadInstructions(addr, inst_offset + inst_count);
+  }
 
   if (!insts.IsValid()) {
 response["success"] = false;
@@ -3930,10

[Lldb-commits] [lldb] WIP: [lldb][test] Workaround older systems that lack gettid (PR #104831)

2024-08-20 Thread Petr Hosek via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb-dap] Fix disassembled ranges for `disassemble` request (PR #105446)

2024-08-20 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
darker --check --diff -r 
82ee31f75ac1316006fa9e21dddfddec37cf7072...b809f570dd8055e5b899c337ec9ff5110ab94c6e
 lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 
lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py
``





View the diff from darker here.


``diff
--- packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 2024-08-20 
00:24:14.00 +
+++ packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py 2024-08-20 
23:09:29.317158 +
@@ -672,11 +672,15 @@
 "arguments": args_dict,
 }
 return self.send_recv(command_dict)
 
 def request_disassemble(
-self, memoryReference, instructionOffset=0, instructionCount=10, 
resolveSymbols=True
+self,
+memoryReference,
+instructionOffset=0,
+instructionCount=10,
+resolveSymbols=True,
 ):
 args_dict = {
 "memoryReference": memoryReference,
 "instructionOffset": instructionOffset,
 "instructionCount": instructionCount,

``




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


[Lldb-commits] [lldb] [lldb/Interpreter] Introduce `ScriptedStopHook{, Python}Interface` & make use of it (PR #105449)

2024-08-20 Thread Med Ismail Bennani via lldb-commits

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

This patch introduces new `ScriptedStopHook{,Python}Interface` classes that 
make use of the Scripted Interface infrastructure and makes use of it in 
`StopHookScripted`.

It also relax the requirement on the number of argument for initializing 
scripting extension if the size of the interface parameter pack contains 1 less 
element than the extension maximum number of positional arguments for this 
initializer.
This addresses the cases where the embedded interpreter session dictionary is 
passed to the extension initializer which is not used most of the time.

>From 78ca8b931a30d13a6817eeea562e15cf373465e1 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Tue, 20 Aug 2024 16:13:54 -0700
Subject: [PATCH 1/3] [lldb/Interpreter] Create
 ScriptedStopHook{,Python}Interface (NFC)

This patch introduces a new scripted interface for ScriptedStopHooks.

This will be used in a follow-up patch to call into the script methods.

Signed-off-by: Med Ismail Bennani 
---
 .../Interfaces/ScriptedStopHookInterface.h| 33 
 .../lldb/Interpreter/ScriptInterpreter.h  |  4 +
 lldb/include/lldb/lldb-forward.h  |  3 +
 .../Python/Interfaces/CMakeLists.txt  |  1 +
 .../ScriptInterpreterPythonInterfaces.cpp |  2 +
 .../ScriptInterpreterPythonInterfaces.h   |  1 +
 .../ScriptedStopHookPythonInterface.cpp   | 75 +++
 .../ScriptedStopHookPythonInterface.h | 50 +
 .../Python/ScriptInterpreterPython.cpp|  5 ++
 .../Python/ScriptInterpreterPythonImpl.h  |  2 +
 10 files changed, 176 insertions(+)
 create mode 100644 
lldb/include/lldb/Interpreter/Interfaces/ScriptedStopHookInterface.h
 create mode 100644 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedStopHookPythonInterface.cpp
 create mode 100644 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedStopHookPythonInterface.h

diff --git 
a/lldb/include/lldb/Interpreter/Interfaces/ScriptedStopHookInterface.h 
b/lldb/include/lldb/Interpreter/Interfaces/ScriptedStopHookInterface.h
new file mode 100644
index 00..125e7f2077b543
--- /dev/null
+++ b/lldb/include/lldb/Interpreter/Interfaces/ScriptedStopHookInterface.h
@@ -0,0 +1,33 @@
+//===-- ScriptedStopHookInterface.h -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLDB_INTERPRETER_INTERFACES_SCRIPTEDSTOPHOOKINTERFACE_H
+#define LLDB_INTERPRETER_INTERFACES_SCRIPTEDSTOPHOOKINTERFACE_H
+
+#include "lldb/lldb-private.h"
+
+#include "ScriptedInterface.h"
+
+namespace lldb_private {
+class ScriptedStopHookInterface : public ScriptedInterface {
+public:
+  virtual llvm::Expected
+  CreatePluginObject(llvm::StringRef class_name, lldb::TargetSP target_sp,
+ const StructuredDataImpl &args_sp) = 0;
+
+  /// "handle_stop" will return a bool with the meaning "should_stop"...
+  /// If nothing is returned, we'll assume we are going to stop.
+  /// Also any errors should return true, since we should stop on error.
+  virtual llvm::Expected HandleStop(ExecutionContext &exe_ctx,
+  lldb::StreamSP output_sp) {
+return true;
+  }
+};
+} // namespace lldb_private
+
+#endif // LLDB_INTERPRETER_INTERFACES_SCRIPTEDSTOPHOOKINTERFACE_H
diff --git a/lldb/include/lldb/Interpreter/ScriptInterpreter.h 
b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
index 89a480a28880aa..71fbb8487e246a 100644
--- a/lldb/include/lldb/Interpreter/ScriptInterpreter.h
+++ b/lldb/include/lldb/Interpreter/ScriptInterpreter.h
@@ -574,6 +574,10 @@ class ScriptInterpreter : public PluginInterface {
 return {};
   }
 
+  virtual lldb::ScriptedStopHookInterfaceSP CreateScriptedStopHookInterface() {
+return {};
+  }
+
   virtual StructuredData::ObjectSP
   CreateStructuredDataFromScriptObject(ScriptObject obj) {
 return {};
diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h
index 337eff696fcf3f..874376e116efd5 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -190,6 +190,7 @@ class ScriptInterpreterLocker;
 class ScriptedMetadata;
 class ScriptedPlatformInterface;
 class ScriptedProcessInterface;
+class ScriptedStopHookInterface;
 class ScriptedThreadInterface;
 class ScriptedThreadPlanInterface;
 class ScriptedSyntheticChildren;
@@ -407,6 +408,8 @@ typedef 
std::unique_ptr
 ScriptedPlatformInterfaceUP;
 typedef std::unique_ptr
 ScriptedProcessInterfaceUP;
+typedef std::shared_ptr
+ScriptedStopHookInterfaceSP;
 typedef std::shared_ptr
 ScriptedThreadInterfaceSP;
 typedef std::shared_ptr
diff --git 
a/lldb/so

[Lldb-commits] [lldb] [lldb/Interpreter] Introduce `ScriptedStopHook{, Python}Interface` & make use of it (PR #105449)

2024-08-20 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Med Ismail Bennani (medismailben)


Changes

This patch introduces new `ScriptedStopHook{,Python}Interface` classes that 
make use of the Scripted Interface infrastructure and makes use of it in 
`StopHookScripted`.

It also relax the requirement on the number of argument for initializing 
scripting extension if the size of the interface parameter pack contains 1 less 
element than the extension maximum number of positional arguments for this 
initializer.
This addresses the cases where the embedded interpreter session dictionary is 
passed to the extension initializer which is not used most of the time.

---

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


20 Files Affected:

- (modified) lldb/bindings/python/python-wrapper.swig (+13-96) 
- (modified) lldb/include/lldb/API/SBExecutionContext.h (+2) 
- (added) lldb/include/lldb/Interpreter/Interfaces/ScriptedStopHookInterface.h 
(+33) 
- (modified) lldb/include/lldb/Interpreter/ScriptInterpreter.h (+8-17) 
- (modified) lldb/include/lldb/Target/Target.h (+1-2) 
- (modified) lldb/include/lldb/lldb-forward.h (+3) 
- (modified) lldb/source/Interpreter/ScriptInterpreter.cpp (+6) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/CMakeLists.txt (+1) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptInterpreterPythonInterfaces.cpp
 (+2) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptInterpreterPythonInterfaces.h
 (+1) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.cpp
 (+18) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedPythonInterface.h
 (+31-6) 
- (added) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedStopHookPythonInterface.cpp
 (+75) 
- (added) 
lldb/source/Plugins/ScriptInterpreter/Python/Interfaces/ScriptedStopHookPythonInterface.h
 (+50) 
- (modified) lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h 
(+1-10) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp 
(+5-50) 
- (modified) 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h (+2) 
- (modified) lldb/source/Target/Target.cpp (+29-10) 
- (modified) 
lldb/test/API/functionalities/scripted_process/dummy_scripted_process.py (+1-1) 
- (modified) lldb/unittests/ScriptInterpreter/Python/PythonTestSuite.cpp (+5-8) 


``diff
diff --git a/lldb/bindings/python/python-wrapper.swig 
b/lldb/bindings/python/python-wrapper.swig
index 2ce42e3e017d5b..28f8e6c849437e 100644
--- a/lldb/bindings/python/python-wrapper.swig
+++ b/lldb/bindings/python/python-wrapper.swig
@@ -301,102 +301,6 @@ unsigned int 
lldb_private::python::SWIGBridge::LLDBSwigPythonCallBreakpointResol
   return ret_val;
 }
 
-PythonObject 
lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedStopHook(
-lldb::TargetSP target_sp, const char *python_class_name,
-const char *session_dictionary_name, const StructuredDataImpl &args_impl,
-Status &error) {
-  if (python_class_name == NULL || python_class_name[0] == '\0') {
-error.SetErrorString("Empty class name.");
-return PythonObject();
-  }
-  if (!session_dictionary_name) {
-error.SetErrorString("No session dictionary");
-return PythonObject();
-  }
-
-  PyErr_Cleaner py_err_cleaner(true);
-
-  auto dict = PythonModule::MainModule().ResolveName(
-  session_dictionary_name);
-  auto pfunc = PythonObject::ResolveNameWithDictionary(
-  python_class_name, dict);
-
-  if (!pfunc.IsAllocated()) {
-error.SetErrorStringWithFormat("Could not find class: %s.",
-   python_class_name);
-return PythonObject();
-  }
-
-  PythonObject result =
-  pfunc(SWIGBridge::ToSWIGWrapper(target_sp), 
SWIGBridge::ToSWIGWrapper(args_impl), dict);
-
-  if (result.IsAllocated()) {
-// Check that the handle_stop callback is defined:
-auto callback_func = result.ResolveName("handle_stop");
-if (callback_func.IsAllocated()) {
-  if (auto args_info = callback_func.GetArgInfo()) {
-size_t num_args = (*args_info).max_positional_args;
-if (num_args != 2) {
-  error.SetErrorStringWithFormat(
-  "Wrong number of args for "
-  "handle_stop callback, should be 2 (excluding self), got: %zu",
-  num_args);
-  return PythonObject();
-} else
-  return result;
-  } else {
-error.SetErrorString("Couldn't get num arguments for handle_stop "
- "callback.");
-return PythonObject();
-  }
-  return result;
-} else {
-  error.SetErrorStringWithFormat("Class \"%s\" is missing the required "
- "handle_stop callback.",
- python_class_name);
-}
-  }
-  retu

[Lldb-commits] [lldb] [lldb-dap] Fix disassembled ranges for `disassemble` request (PR #105446)

2024-08-20 Thread Adrian Vogelsgesang via lldb-commits

vogelsgesang wrote:

@clayborg I would be interested in your guidance for this PR, given that you 
previously reviewed a similar change in https://reviews.llvm.org/D140358

I did use `SBFunction` / `SBSymbol` as suggested by you in [this 
comment](https://reviews.llvm.org/D140358#4027551). 

I did not know how to address the part

```
// then we need to repeat the search for the next function or symbol. 
// note there may be bytes between functions or symbols which we can 
disassemble
// by calling _get_instructions_from_memory(...) but we must find the next
// symbol or function boundary and get back on track
```

from your comment, though. Is there some API to find the next symbol? Or some 
API to get a list of symbols, sorted by their start address?

I could of course use a brute-force approach, similar to

```
SBAddress addr;
while (!addr.GetFunction() && !addr.GetSymbol())
   addr = addr.OffsetAddress(1);
```

but that seems a bit wasteful

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


[Lldb-commits] [lldb] [lldb-dap] When sending a DAP Output Event break each message into separate lines. (PR #105456)

2024-08-20 Thread John Harrison via lldb-commits

https://github.com/ashgti created 
https://github.com/llvm/llvm-project/pull/105456

Previously, when output like `"hello\nworld\n"` was produced by lldb (or the 
process) the message would be sent as a single Output event. By being a single 
event this causes VS Code to treat this as a single message in the console when 
handling displaying and filtering in the Debug Console.

Instead, with these changes we send each line as its own event. This results in 
VS Code representing each line of output from lldb-dap as an individual output 
message.

Resolves #105444


>From 9246649c24991127b8f54ae1f21121386cef7254 Mon Sep 17 00:00:00 2001
From: John Harrison 
Date: Tue, 20 Aug 2024 16:33:14 -0700
Subject: [PATCH] When sending a DAP Output Event break each message into
 separate lines.

Previously, when output like `"hello\nworld\n"` was produced by lldb (or the 
process) the message would be sent as a single Output event.
By being a single event this causes VS Code to treat this as a single message 
in the console when handling displaying and filtering in the Debug Console.

Instead, with these changes we send each line as its own event. This results in 
VS Code representing each line of output from lldb-dap as an individual output 
message.
---
 .../test/tools/lldb-dap/lldbdap_testcase.py   |  5 +++
 lldb/test/API/tools/lldb-dap/output/Makefile  |  3 ++
 .../tools/lldb-dap/output/TestDAP_output.py   | 37 +++
 lldb/test/API/tools/lldb-dap/output/main.c| 11 ++
 lldb/tools/lldb-dap/DAP.cpp   | 22 ---
 5 files changed, 72 insertions(+), 6 deletions(-)
 create mode 100644 lldb/test/API/tools/lldb-dap/output/Makefile
 create mode 100644 lldb/test/API/tools/lldb-dap/output/TestDAP_output.py
 create mode 100644 lldb/test/API/tools/lldb-dap/output/main.c

diff --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
index a312a88ebd7e58..8341bfda748206 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py
@@ -202,6 +202,11 @@ def collect_console(self, timeout_secs, pattern=None):
 "console", timeout_secs=timeout_secs, pattern=pattern
 )
 
+def collect_stdout(self, timeout_secs, pattern=None):
+return self.dap_server.collect_output(
+"stdout", timeout_secs=timeout_secs, pattern=pattern
+)
+
 def get_local_as_int(self, name, threadId=None):
 value = self.dap_server.get_local_variable_value(name, 
threadId=threadId)
 # 'value' may have the variable value and summary.
diff --git a/lldb/test/API/tools/lldb-dap/output/Makefile 
b/lldb/test/API/tools/lldb-dap/output/Makefile
new file mode 100644
index 00..10495940055b63
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/output/Makefile
@@ -0,0 +1,3 @@
+C_SOURCES := main.c
+
+include Makefile.rules
diff --git a/lldb/test/API/tools/lldb-dap/output/TestDAP_output.py 
b/lldb/test/API/tools/lldb-dap/output/TestDAP_output.py
new file mode 100644
index 00..08d5f07f224e4c
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/output/TestDAP_output.py
@@ -0,0 +1,37 @@
+"""
+Test lldb-dap output events
+"""
+
+import dap_server
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+import lldbdap_testcase
+import re
+
+
+class TestDAP_output(lldbdap_testcase.DAPTestCaseBase):
+def test_output(self):
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+source = "main.c"
+main_source_path = self.getSourcePath(source)
+lines = [line_number(source, "// breakpoint 1")]
+breakpoint_ids = self.set_source_breakpoints(source, lines)
+self.continue_to_breakpoints(breakpoint_ids)
+
+output = self.collect_stdout(
+timeout_secs=1.0,
+pattern="abcdef"
+)
+self.assertTrue(output and len(output) > 0, "expect no program output")
+
+self.continue_to_exit()
+
+output += 
self.get_stdout(timeout=lldbdap_testcase.DAPTestCaseBase.timeoutval)
+self.assertTrue(output and len(output) > 0, "expect no program output")
+self.assertIn(
+"abcdefghi\r\nhello world\r\n",
+output,
+'full output not found in: ' + output
+)
diff --git a/lldb/test/API/tools/lldb-dap/output/main.c 
b/lldb/test/API/tools/lldb-dap/output/main.c
new file mode 100644
index 00..62a3337d865db2
--- /dev/null
+++ b/lldb/test/API/tools/lldb-dap/output/main.c
@@ -0,0 +1,11 @@
+#include 
+#include 
+#include 
+
+int main() {
+  printf("abc");
+  printf("def");
+  printf("ghi\n");
+  printf("hello world\n"); // breakpoint 1
+  return 0;
+}
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 

  1   2   >