[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-06 Thread Dmitry Vasilyev via lldb-commits

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

The different build configuration and target Linux system can load a different 
number of .so libraries (2 and more). As example, Linux x86_64 host shows the 
following loaded modules:
```
Loaded files: ld-linux-x86-64.so.2
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libstdc++.so.6, libm.so.6, libgcc_s.so.1, libc.so.6
```
avg_solibs_added_per_event = 1.75

But Linux Aarch64 (remote target) with statically linked C++ library (clang) 
shows:
```
Loaded files: ld-2.31.so
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libm.so.6, libc.so.6
```
avg_solibs_added_per_event = 1.25

Increase precision by 1 digit to fix the test.

>From 3f91ecacdcf1eedc95b72e8a85591e60a863431e Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 6 Jun 2024 23:38:03 +0400
Subject: [PATCH] [lldb] Fix TestModuleLoadedNotifys API test to work correctly
 on most of Linux targets.

The different build configuration and target Linux system can load a different 
number of .so libraries (2 and more).
As example, Linux x86_64 host shows the following loaded modules:
```
Loaded files: ld-linux-x86-64.so.2
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libstdc++.so.6, libm.so.6, libgcc_s.so.1, libc.so.6
```
avg_solibs_added_per_event = 1.75

But Linux Aarch64 (remote target) with statically linked C++ library (clang) 
shows:
```
Loaded files: ld-2.31.so
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libm.so.6, libc.so.6
```
avg_solibs_added_per_event = 1.25

Increase precision by 1 digit to fix the test.
---
 .../target-new-solib-notifications/TestModuleLoadedNotifys.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index abf761fb3420b..28a1026ae4fcc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -118,6 +118,6 @@ def test_launch_notifications(self):
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
 avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
 )
-self.assertGreater(avg_solibs_added_per_event, 1)
+self.assertGreater(avg_solibs_added_per_event, 10)

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-06 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

The different build configuration and target Linux system can load a different 
number of .so libraries (2 and more). As example, Linux x86_64 host shows the 
following loaded modules:
```
Loaded files: ld-linux-x86-64.so.2
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libstdc++.so.6, libm.so.6, libgcc_s.so.1, libc.so.6
```
avg_solibs_added_per_event = 1.75

But Linux Aarch64 (remote target) with statically linked C++ library (clang) 
shows:
```
Loaded files: ld-2.31.so
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libm.so.6, libc.so.6
```
avg_solibs_added_per_event = 1.25

Increase precision by 1 digit to fix the test.

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


1 Files Affected:

- (modified) 
lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 (+2-2) 


``diff
diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index abf761fb3420b..28a1026ae4fcc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -118,6 +118,6 @@ def test_launch_notifications(self):
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
 avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
 )
-self.assertGreater(avg_solibs_added_per_event, 1)
+self.assertGreater(avg_solibs_added_per_event, 10)

``




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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-07 Thread Pavel Labath via lldb-commits


@@ -118,6 +118,6 @@ def test_launch_notifications(self):
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
 avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+10.0 * float(total_solibs_added) / 
float(total_modules_added_events)

labath wrote:

You can't really call it "number of libraries per event" anymore if you 
multiply by ten. It's more like number of decilibraries/event :P. Maybe you 
could just remove the round call, and compare to 1.0, but I'm wondering if this 
is even the right metric for the test. Since what we're trying to check is that 
we don't send these notifications one by one, I think some check like "number 
of events with more than one module" or "number of total events" (or both) 
would be better. @jasonmolenda, what do you think?

Also, this test is very unhermetic in the sense that it depends on the 
environment to provide enough shared libraries to measure. In the extreme case 
we could have a totally statically linked binary and zero shared libraries. So, 
another way to make this test be more resilient is to introduce a couple of 
shared libraries of our own, so that we can be sure there is something to 
measure. You could copy the pattern from TestLoadUnload.py to link a bunch of 
shared libraries to this binary.

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-07 Thread Dmitry Vasilyev via lldb-commits


@@ -118,6 +118,6 @@ def test_launch_notifications(self):
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
 avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+10.0 * float(total_solibs_added) / 
float(total_modules_added_events)

slydiman wrote:

> You can't really call it "number of libraries per event" anymore if you 
> multiply by ten.

avg10_solibs_added_per_event ?

> Maybe you could just remove the round call, and compare to 1.0 

No, because assertGreater() expects int parameters.

> Also, this test is very unhermetic

Right, and it seems that the behavior on Darwin is very different. I'd just 
check `min_modules_per_event >= 1`.


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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-07 Thread Dmitry Vasilyev via lldb-commits

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

>From 3f91ecacdcf1eedc95b72e8a85591e60a863431e Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 6 Jun 2024 23:38:03 +0400
Subject: [PATCH 1/2] [lldb] Fix TestModuleLoadedNotifys API test to work
 correctly on most of Linux targets.

The different build configuration and target Linux system can load a different 
number of .so libraries (2 and more).
As example, Linux x86_64 host shows the following loaded modules:
```
Loaded files: ld-linux-x86-64.so.2
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libstdc++.so.6, libm.so.6, libgcc_s.so.1, libc.so.6
```
avg_solibs_added_per_event = 1.75

But Linux Aarch64 (remote target) with statically linked C++ library (clang) 
shows:
```
Loaded files: ld-2.31.so
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libm.so.6, libc.so.6
```
avg_solibs_added_per_event = 1.25

Increase precision by 1 digit to fix the test.
---
 .../target-new-solib-notifications/TestModuleLoadedNotifys.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index abf761fb3420b..28a1026ae4fcc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -118,6 +118,6 @@ def test_launch_notifications(self):
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
 avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
 )
-self.assertGreater(avg_solibs_added_per_event, 1)
+self.assertGreater(avg_solibs_added_per_event, 10)

>From 0518bff0710a8f4404847e1cd28c6bcdbbb00093 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Fri, 7 Jun 2024 12:36:44 +0400
Subject: [PATCH 2/2] Keep the `avg_solibs_added_per_event` name correct.

---
 .../TestModuleLoadedNotifys.py  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index 28a1026ae4fcc..ef407abce59fc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -117,7 +117,7 @@ def test_launch_notifications(self):
 # program: a.out and dyld, and then all the rest of the system 
libraries.
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
-avg_solibs_added_per_event = round(
-10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
+avg_solibs_added_per_event = float(total_solibs_added) / float(
+total_modules_added_events
 )
-self.assertGreater(avg_solibs_added_per_event, 10)
+self.assertGreater(round(10.0 * avg_solibs_added_per_event), 10)

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-07 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

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

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

>From 3f91ecacdcf1eedc95b72e8a85591e60a863431e Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 6 Jun 2024 23:38:03 +0400
Subject: [PATCH 1/3] [lldb] Fix TestModuleLoadedNotifys API test to work
 correctly on most of Linux targets.

The different build configuration and target Linux system can load a different 
number of .so libraries (2 and more).
As example, Linux x86_64 host shows the following loaded modules:
```
Loaded files: ld-linux-x86-64.so.2
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libstdc++.so.6, libm.so.6, libgcc_s.so.1, libc.so.6
```
avg_solibs_added_per_event = 1.75

But Linux Aarch64 (remote target) with statically linked C++ library (clang) 
shows:
```
Loaded files: ld-2.31.so
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libm.so.6, libc.so.6
```
avg_solibs_added_per_event = 1.25

Increase precision by 1 digit to fix the test.
---
 .../target-new-solib-notifications/TestModuleLoadedNotifys.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index abf761fb3420b..28a1026ae4fcc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -118,6 +118,6 @@ def test_launch_notifications(self):
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
 avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
 )
-self.assertGreater(avg_solibs_added_per_event, 1)
+self.assertGreater(avg_solibs_added_per_event, 10)

>From 0518bff0710a8f4404847e1cd28c6bcdbbb00093 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Fri, 7 Jun 2024 12:36:44 +0400
Subject: [PATCH 2/3] Keep the `avg_solibs_added_per_event` name correct.

---
 .../TestModuleLoadedNotifys.py  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index 28a1026ae4fcc..ef407abce59fc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -117,7 +117,7 @@ def test_launch_notifications(self):
 # program: a.out and dyld, and then all the rest of the system 
libraries.
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
-avg_solibs_added_per_event = round(
-10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
+avg_solibs_added_per_event = float(total_solibs_added) / float(
+total_modules_added_events
 )
-self.assertGreater(avg_solibs_added_per_event, 10)
+self.assertGreater(round(10.0 * avg_solibs_added_per_event), 10)

>From 6fb19a05a6a4fb4463035bcd35a53fc51e446a05 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sat, 8 Jun 2024 12:53:06 +0400
Subject: [PATCH 3/3] Added own so modules.

---
 .../target-new-solib-notifications/Makefile   | 26 +++--
 .../TestModuleLoadedNotifys.py| 53 ---
 .../target-new-solib-notifications/a.cpp  | 14 +
 .../target-new-solib-notifications/b.cpp  |  9 
 .../target-new-solib-notifications/c.cpp  |  5 ++
 .../target-new-solib-notifications/d.cpp  | 10 
 .../target-new-solib-notifications/main.cpp   | 24 ++---
 7 files changed, 124 insertions(+), 17 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/a.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/b.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/c.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/d.cpp

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/Makefile 
b/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
index 8b20bcb05..50169c0ae1b80 100644
--- a/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
+++ b/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
@@ -1,3 +1,23 @@
-CXX_SOURCES := main.cpp
-
-include Makefile.rules
+CXX_SOURCES := main.cpp
+LD_EXTRAS := -L. -lloadunload_d -lloadunload_c -lloadunload_a -lloadunload_b
+
+a.out: lib_b lib_a lib_c lib_d
+
+include Makefile.rules
+
+lib_a: lib_b
+ 

[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

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


@@ -118,6 +118,6 @@ def test_launch_notifications(self):
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
 avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+10.0 * float(total_solibs_added) / 
float(total_modules_added_events)

slydiman wrote:

@labath 
> So, another way to make this test be more resilient is to introduce a couple 
> of shared libraries of our own

The patch is updated this way. Please review. Thanks.

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-08 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 fb0c705dbf27e3ab84d726ad30e172806a530c21 
6fb19a05a6a4fb4463035bcd35a53fc51e446a05 -- 
lldb/test/API/functionalities/target-new-solib-notifications/a.cpp 
lldb/test/API/functionalities/target-new-solib-notifications/b.cpp 
lldb/test/API/functionalities/target-new-solib-notifications/c.cpp 
lldb/test/API/functionalities/target-new-solib-notifications/d.cpp 
lldb/test/API/functionalities/target-new-solib-notifications/main.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/test/API/functionalities/target-new-solib-notifications/a.cpp 
b/lldb/test/API/functionalities/target-new-solib-notifications/a.cpp
index 5d0ab4030e..88c59bd7be 100644
--- a/lldb/test/API/functionalities/target-new-solib-notifications/a.cpp
+++ b/lldb/test/API/functionalities/target-new-solib-notifications/a.cpp
@@ -1,14 +1,7 @@
 extern "C" int b_function();
 
-int a_init()
-{
-return 234;
-}
+int a_init() { return 234; }
 
 int a_global = a_init();
 
-extern "C" int
-a_function ()
-{
-return b_function ();
-}
+extern "C" int a_function() { return b_function(); }
diff --git a/lldb/test/API/functionalities/target-new-solib-notifications/b.cpp 
b/lldb/test/API/functionalities/target-new-solib-notifications/b.cpp
index ddb2d97fbd..908282f06a 100644
--- a/lldb/test/API/functionalities/target-new-solib-notifications/b.cpp
+++ b/lldb/test/API/functionalities/target-new-solib-notifications/b.cpp
@@ -1,9 +1,5 @@
-int b_init()
-{
-return 345;
-}
+int b_init() { return 345; }
 
 int b_global = b_init();
 
-extern "C"
-int b_function() { return 500; }
+extern "C" int b_function() { return 500; }
diff --git a/lldb/test/API/functionalities/target-new-solib-notifications/c.cpp 
b/lldb/test/API/functionalities/target-new-solib-notifications/c.cpp
index 13ab26b4c4..8abd1b155a 100644
--- a/lldb/test/API/functionalities/target-new-solib-notifications/c.cpp
+++ b/lldb/test/API/functionalities/target-new-solib-notifications/c.cpp
@@ -1,5 +1 @@
-extern "C" int
-c_function ()
-{
-return 600;
-}
+extern "C" int c_function() { return 600; }
diff --git a/lldb/test/API/functionalities/target-new-solib-notifications/d.cpp 
b/lldb/test/API/functionalities/target-new-solib-notifications/d.cpp
index 13f9934745..85882b4ce9 100644
--- a/lldb/test/API/functionalities/target-new-solib-notifications/d.cpp
+++ b/lldb/test/API/functionalities/target-new-solib-notifications/d.cpp
@@ -1,7 +1,4 @@
-int d_init()
-{
-return 123;
-}
+int d_init() { return 123; }
 
 int d_global = d_init();
 
diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/main.cpp 
b/lldb/test/API/functionalities/target-new-solib-notifications/main.cpp
index f7c4555e02..9efac88643 100644
--- a/lldb/test/API/functionalities/target-new-solib-notifications/main.cpp
+++ b/lldb/test/API/functionalities/target-new-solib-notifications/main.cpp
@@ -1,12 +1,11 @@
 #include 
 
-extern "C" int a_function ();
-extern "C" int c_function ();
-extern "C" int b_function ();
-extern "C" int d_function ();
+extern "C" int a_function();
+extern "C" int c_function();
+extern "C" int b_function();
+extern "C" int d_function();
 
-int main ()
-{
+int main() {
   a_function();
   b_function();
   c_function();

``




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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

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

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

>From 3f91ecacdcf1eedc95b72e8a85591e60a863431e Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 6 Jun 2024 23:38:03 +0400
Subject: [PATCH 1/3] [lldb] Fix TestModuleLoadedNotifys API test to work
 correctly on most of Linux targets.

The different build configuration and target Linux system can load a different 
number of .so libraries (2 and more).
As example, Linux x86_64 host shows the following loaded modules:
```
Loaded files: ld-linux-x86-64.so.2
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libstdc++.so.6, libm.so.6, libgcc_s.so.1, libc.so.6
```
avg_solibs_added_per_event = 1.75

But Linux Aarch64 (remote target) with statically linked C++ library (clang) 
shows:
```
Loaded files: ld-2.31.so
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libm.so.6, libc.so.6
```
avg_solibs_added_per_event = 1.25

Increase precision by 1 digit to fix the test.
---
 .../target-new-solib-notifications/TestModuleLoadedNotifys.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index abf761fb3420b..28a1026ae4fcc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -118,6 +118,6 @@ def test_launch_notifications(self):
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
 avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
 )
-self.assertGreater(avg_solibs_added_per_event, 1)
+self.assertGreater(avg_solibs_added_per_event, 10)

>From 0518bff0710a8f4404847e1cd28c6bcdbbb00093 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Fri, 7 Jun 2024 12:36:44 +0400
Subject: [PATCH 2/3] Keep the `avg_solibs_added_per_event` name correct.

---
 .../TestModuleLoadedNotifys.py  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index 28a1026ae4fcc..ef407abce59fc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -117,7 +117,7 @@ def test_launch_notifications(self):
 # program: a.out and dyld, and then all the rest of the system 
libraries.
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
-avg_solibs_added_per_event = round(
-10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
+avg_solibs_added_per_event = float(total_solibs_added) / float(
+total_modules_added_events
 )
-self.assertGreater(avg_solibs_added_per_event, 10)
+self.assertGreater(round(10.0 * avg_solibs_added_per_event), 10)

>From 2e2b3087be5763e73136b391f6b666067dea036c Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sat, 8 Jun 2024 12:53:06 +0400
Subject: [PATCH 3/3] Added own so modules.

---
 .../target-new-solib-notifications/Makefile   | 26 +++--
 .../TestModuleLoadedNotifys.py| 53 ---
 .../target-new-solib-notifications/a.cpp  | 14 +
 .../target-new-solib-notifications/b.cpp  |  9 
 .../target-new-solib-notifications/c.cpp  |  5 ++
 .../target-new-solib-notifications/d.cpp  | 10 
 .../target-new-solib-notifications/main.cpp   | 23 +---
 7 files changed, 123 insertions(+), 17 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/a.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/b.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/c.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/d.cpp

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/Makefile 
b/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
index 8b20bcb05..50169c0ae1b80 100644
--- a/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
+++ b/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
@@ -1,3 +1,23 @@
-CXX_SOURCES := main.cpp
-
-include Makefile.rules
+CXX_SOURCES := main.cpp
+LD_EXTRAS := -L. -lloadunload_d -lloadunload_c -lloadunload_a -lloadunload_b
+
+a.out: lib_b lib_a lib_c lib_d
+
+include Makefile.rules
+
+lib_a: lib_b
+  

[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

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

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

>From 3f91ecacdcf1eedc95b72e8a85591e60a863431e Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 6 Jun 2024 23:38:03 +0400
Subject: [PATCH 1/3] [lldb] Fix TestModuleLoadedNotifys API test to work
 correctly on most of Linux targets.

The different build configuration and target Linux system can load a different 
number of .so libraries (2 and more).
As example, Linux x86_64 host shows the following loaded modules:
```
Loaded files: ld-linux-x86-64.so.2
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libstdc++.so.6, libm.so.6, libgcc_s.so.1, libc.so.6
```
avg_solibs_added_per_event = 1.75

But Linux Aarch64 (remote target) with statically linked C++ library (clang) 
shows:
```
Loaded files: ld-2.31.so
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libm.so.6, libc.so.6
```
avg_solibs_added_per_event = 1.25

Increase precision by 1 digit to fix the test.
---
 .../target-new-solib-notifications/TestModuleLoadedNotifys.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index abf761fb3420b..28a1026ae4fcc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -118,6 +118,6 @@ def test_launch_notifications(self):
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
 avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
 )
-self.assertGreater(avg_solibs_added_per_event, 1)
+self.assertGreater(avg_solibs_added_per_event, 10)

>From 0518bff0710a8f4404847e1cd28c6bcdbbb00093 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Fri, 7 Jun 2024 12:36:44 +0400
Subject: [PATCH 2/3] Keep the `avg_solibs_added_per_event` name correct.

---
 .../TestModuleLoadedNotifys.py  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index 28a1026ae4fcc..ef407abce59fc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -117,7 +117,7 @@ def test_launch_notifications(self):
 # program: a.out and dyld, and then all the rest of the system 
libraries.
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
-avg_solibs_added_per_event = round(
-10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
+avg_solibs_added_per_event = float(total_solibs_added) / float(
+total_modules_added_events
 )
-self.assertGreater(avg_solibs_added_per_event, 10)
+self.assertGreater(round(10.0 * avg_solibs_added_per_event), 10)

>From 0aec72ad777be192d0dd0fc0aba5a52fd0767ada Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sat, 8 Jun 2024 12:53:06 +0400
Subject: [PATCH 3/3] Added own so modules.

---
 .../target-new-solib-notifications/Makefile   | 26 +++--
 .../TestModuleLoadedNotifys.py| 53 ---
 .../target-new-solib-notifications/a.cpp  | 14 +
 .../target-new-solib-notifications/b.cpp  |  9 
 .../target-new-solib-notifications/c.cpp  |  5 ++
 .../target-new-solib-notifications/d.cpp  | 10 
 .../target-new-solib-notifications/main.cpp   | 23 +---
 7 files changed, 123 insertions(+), 17 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/a.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/b.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/c.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/d.cpp

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/Makefile 
b/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
index 8b20bcb05..50169c0ae1b80 100644
--- a/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
+++ b/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
@@ -1,3 +1,23 @@
-CXX_SOURCES := main.cpp
-
-include Makefile.rules
+CXX_SOURCES := main.cpp
+LD_EXTRAS := -L. -lloadunload_d -lloadunload_c -lloadunload_a -lloadunload_b
+
+a.out: lib_b lib_a lib_c lib_d
+
+include Makefile.rules
+
+lib_a: lib_b
+  

[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

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

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

>From 3f91ecacdcf1eedc95b72e8a85591e60a863431e Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 6 Jun 2024 23:38:03 +0400
Subject: [PATCH 1/3] [lldb] Fix TestModuleLoadedNotifys API test to work
 correctly on most of Linux targets.

The different build configuration and target Linux system can load a different 
number of .so libraries (2 and more).
As example, Linux x86_64 host shows the following loaded modules:
```
Loaded files: ld-linux-x86-64.so.2
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libstdc++.so.6, libm.so.6, libgcc_s.so.1, libc.so.6
```
avg_solibs_added_per_event = 1.75

But Linux Aarch64 (remote target) with statically linked C++ library (clang) 
shows:
```
Loaded files: ld-2.31.so
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libm.so.6, libc.so.6
```
avg_solibs_added_per_event = 1.25

Increase precision by 1 digit to fix the test.
---
 .../target-new-solib-notifications/TestModuleLoadedNotifys.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index abf761fb3420b..28a1026ae4fcc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -118,6 +118,6 @@ def test_launch_notifications(self):
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
 avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
 )
-self.assertGreater(avg_solibs_added_per_event, 1)
+self.assertGreater(avg_solibs_added_per_event, 10)

>From 0518bff0710a8f4404847e1cd28c6bcdbbb00093 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Fri, 7 Jun 2024 12:36:44 +0400
Subject: [PATCH 2/3] Keep the `avg_solibs_added_per_event` name correct.

---
 .../TestModuleLoadedNotifys.py  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index 28a1026ae4fcc..ef407abce59fc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -117,7 +117,7 @@ def test_launch_notifications(self):
 # program: a.out and dyld, and then all the rest of the system 
libraries.
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
-avg_solibs_added_per_event = round(
-10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
+avg_solibs_added_per_event = float(total_solibs_added) / float(
+total_modules_added_events
 )
-self.assertGreater(avg_solibs_added_per_event, 10)
+self.assertGreater(round(10.0 * avg_solibs_added_per_event), 10)

>From d7832a1181613caeb68c597db17680c3c6008de8 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sat, 8 Jun 2024 12:53:06 +0400
Subject: [PATCH 3/3] Added own so modules.

---
 .../target-new-solib-notifications/Makefile   | 26 +++--
 .../TestModuleLoadedNotifys.py| 53 ---
 .../target-new-solib-notifications/a.cpp  |  7 +++
 .../target-new-solib-notifications/b.cpp  |  5 ++
 .../target-new-solib-notifications/c.cpp  |  1 +
 .../target-new-solib-notifications/d.cpp  |  5 ++
 .../target-new-solib-notifications/main.cpp   | 22 +---
 7 files changed, 102 insertions(+), 17 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/a.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/b.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/c.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/d.cpp

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/Makefile 
b/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
index 8b20bcb05..50169c0ae1b80 100644
--- a/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
+++ b/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
@@ -1,3 +1,23 @@
-CXX_SOURCES := main.cpp
-
-include Makefile.rules
+CXX_SOURCES := main.cpp
+LD_EXTRAS := -L. -lloadunload_d -lloadunload_c -lloadunload_a -lloadunload_b
+
+a.out: lib_b lib_a lib_c lib_d
+
+include Makefile.rules
+
+lib_a: lib_b
+   $(MAKE

[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

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

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

>From 3f91ecacdcf1eedc95b72e8a85591e60a863431e Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 6 Jun 2024 23:38:03 +0400
Subject: [PATCH 1/3] [lldb] Fix TestModuleLoadedNotifys API test to work
 correctly on most of Linux targets.

The different build configuration and target Linux system can load a different 
number of .so libraries (2 and more).
As example, Linux x86_64 host shows the following loaded modules:
```
Loaded files: ld-linux-x86-64.so.2
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libstdc++.so.6, libm.so.6, libgcc_s.so.1, libc.so.6
```
avg_solibs_added_per_event = 1.75

But Linux Aarch64 (remote target) with statically linked C++ library (clang) 
shows:
```
Loaded files: ld-2.31.so
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libm.so.6, libc.so.6
```
avg_solibs_added_per_event = 1.25

Increase precision by 1 digit to fix the test.
---
 .../target-new-solib-notifications/TestModuleLoadedNotifys.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index abf761fb3420b..28a1026ae4fcc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -118,6 +118,6 @@ def test_launch_notifications(self):
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
 avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
 )
-self.assertGreater(avg_solibs_added_per_event, 1)
+self.assertGreater(avg_solibs_added_per_event, 10)

>From 0518bff0710a8f4404847e1cd28c6bcdbbb00093 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Fri, 7 Jun 2024 12:36:44 +0400
Subject: [PATCH 2/3] Keep the `avg_solibs_added_per_event` name correct.

---
 .../TestModuleLoadedNotifys.py  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index 28a1026ae4fcc..ef407abce59fc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -117,7 +117,7 @@ def test_launch_notifications(self):
 # program: a.out and dyld, and then all the rest of the system 
libraries.
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
-avg_solibs_added_per_event = round(
-10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
+avg_solibs_added_per_event = float(total_solibs_added) / float(
+total_modules_added_events
 )
-self.assertGreater(avg_solibs_added_per_event, 10)
+self.assertGreater(round(10.0 * avg_solibs_added_per_event), 10)

>From 60671ecc918692bba6d937bc7590eae55fd20514 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sat, 8 Jun 2024 12:53:06 +0400
Subject: [PATCH 3/3] Added own so modules.

---
 .../target-new-solib-notifications/Makefile   | 26 +++--
 .../TestModuleLoadedNotifys.py| 53 ---
 .../target-new-solib-notifications/a.cpp  |  7 +++
 .../target-new-solib-notifications/b.cpp  |  5 ++
 .../target-new-solib-notifications/c.cpp  |  1 +
 .../target-new-solib-notifications/d.cpp  |  5 ++
 .../target-new-solib-notifications/main.cpp   | 22 +---
 7 files changed, 102 insertions(+), 17 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/a.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/b.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/c.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/d.cpp

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/Makefile 
b/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
index 8b20bcb05..50169c0ae1b80 100644
--- a/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
+++ b/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
@@ -1,3 +1,23 @@
-CXX_SOURCES := main.cpp
-
-include Makefile.rules
+CXX_SOURCES := main.cpp
+LD_EXTRAS := -L. -lloadunload_d -lloadunload_c -lloadunload_a -lloadunload_b
+
+a.out: lib_b lib_a lib_c lib_d
+
+include Makefile.rules
+
+lib_a: lib_b
+   $(MAKE

[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-10 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-10 Thread Pavel Labath via lldb-commits


@@ -0,0 +1,7 @@
+extern "C" int b_function();
+
+int a_init() { return 234; }
+
+int a_global = a_init();

labath wrote:

Just delete all of this stuff, as it's not relevant for what we're testing. 
(the `a_function` -> `b_function` dep is marginally interesting, as it creates 
a more interesting dependency graph).

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-10 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

This is great stuff, just a couple of details

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-10 Thread Pavel Labath via lldb-commits


@@ -9,22 +9,51 @@
 from lldbsuite.test import lldbutil
 
 
+@skipUnlessPlatform(["linux"] + lldbplatformutil.getDarwinOSTriples())
 class ModuleLoadedNotifysTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
 # At least DynamicLoaderDarwin and DynamicLoaderPOSIXDYLD should batch up
 # notifications about newly added/removed libraries.  Other DynamicLoaders 
may
 # not be written this way.
-@skipUnlessPlatform(["linux"] + lldbplatformutil.getDarwinOSTriples())
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
 # Find the line number to break inside main().
 self.line = line_number("main.cpp", "// breakpoint")
 
+def setup_test(self, solibs):
+if lldb.remote_platform:
+path = lldb.remote_platform.GetWorkingDirectory()
+for f in solibs:
+lldbutil.install_to_target(self, self.getBuildArtifact(f))
+else:
+path = self.getBuildDir()
+if self.dylibPath in os.environ:
+sep = self.platformContext.shlib_path_separator
+path = os.environ[self.dylibPath] + sep + path
+self.runCmd(
+"settings append target.env-vars '{}={}'".format(self.dylibPath, 
path)
+)
+self.default_path = path
+
 def test_launch_notifications(self):
 """Test that lldb broadcasts newly loaded libraries in batches."""
+
+ext = "so"
+if self.platformIsDarwin():
+ext = "dylib"

labath wrote:

You should be able to get this as `self.platformContext.shlib_extension`

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-10 Thread Pavel Labath via lldb-commits


@@ -1,3 +1,23 @@
-CXX_SOURCES := main.cpp
-
-include Makefile.rules
+CXX_SOURCES := main.cpp
+LD_EXTRAS := -L. -lloadunload_d -lloadunload_c -lloadunload_a -lloadunload_b

labath wrote:

Please rename the modules to something else (even a simple `liba` is probably 
fine).

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-10 Thread Pavel Labath via lldb-commits


@@ -115,9 +151,10 @@ def test_launch_notifications(self):
 # binaries in batches.  Check that we got back more than 1 solib per 
event.
 # In practice on Darwin today, we get back two events for a do-nothing 
c
 # program: a.out and dyld, and then all the rest of the system 
libraries.
-# On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
-
-avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+# On Linux we get events for ld.so, [vdso], the binary and then all 
libraries,
+# but the different configurations could load a different number of 
.so modules
+# per event.
+self.assertGreaterEqual(
+len(set(max_solib_chunk_per_event).intersection(expected_solibs)),
+len(expected_solibs),

labath wrote:

I think this could be `assertLess(set(expected_solibs), 
set(max_solib_chunk_per_event))` (with the advantage being that you'd bet a 
better error message than `3 is not less than 4` when it fails.

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-10 Thread Pavel Labath via lldb-commits


@@ -118,6 +118,6 @@ def test_launch_notifications(self):
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
 avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+10.0 * float(total_solibs_added) / 
float(total_modules_added_events)

labath wrote:

> > You can't really call it "number of libraries per event" anymore if you 
> > multiply by ten.
> 
> I have updated the patch.
> 
> > Maybe you could just remove the round call, and compare to 1.0
> 
> No, because assertGreater() expects int parameters.

That's strange because `assertGreater(47.0001, 47.)` works just fine for 
me. So does `assertLessEqual(set(["a", "b"]), set(["a", "b"]))`.

Could it be that you're still running on the version of lldb that has the 
ancient checked in copy of `unittest`?


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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-10 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-10 Thread Dmitry Vasilyev via lldb-commits

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

>From 3f91ecacdcf1eedc95b72e8a85591e60a863431e Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Thu, 6 Jun 2024 23:38:03 +0400
Subject: [PATCH 1/4] [lldb] Fix TestModuleLoadedNotifys API test to work
 correctly on most of Linux targets.

The different build configuration and target Linux system can load a different 
number of .so libraries (2 and more).
As example, Linux x86_64 host shows the following loaded modules:
```
Loaded files: ld-linux-x86-64.so.2
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libstdc++.so.6, libm.so.6, libgcc_s.so.1, libc.so.6
```
avg_solibs_added_per_event = 1.75

But Linux Aarch64 (remote target) with statically linked C++ library (clang) 
shows:
```
Loaded files: ld-2.31.so
Loaded files: [vdso]
Loaded files: a.out
Loaded files: libm.so.6, libc.so.6
```
avg_solibs_added_per_event = 1.25

Increase precision by 1 digit to fix the test.
---
 .../target-new-solib-notifications/TestModuleLoadedNotifys.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index abf761fb3420b..28a1026ae4fcc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -118,6 +118,6 @@ def test_launch_notifications(self):
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
 avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
 )
-self.assertGreater(avg_solibs_added_per_event, 1)
+self.assertGreater(avg_solibs_added_per_event, 10)

>From 0518bff0710a8f4404847e1cd28c6bcdbbb00093 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Fri, 7 Jun 2024 12:36:44 +0400
Subject: [PATCH 2/4] Keep the `avg_solibs_added_per_event` name correct.

---
 .../TestModuleLoadedNotifys.py  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
index 28a1026ae4fcc..ef407abce59fc 100644
--- 
a/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
+++ 
b/lldb/test/API/functionalities/target-new-solib-notifications/TestModuleLoadedNotifys.py
@@ -117,7 +117,7 @@ def test_launch_notifications(self):
 # program: a.out and dyld, and then all the rest of the system 
libraries.
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
-avg_solibs_added_per_event = round(
-10.0 * float(total_solibs_added) / 
float(total_modules_added_events)
+avg_solibs_added_per_event = float(total_solibs_added) / float(
+total_modules_added_events
 )
-self.assertGreater(avg_solibs_added_per_event, 10)
+self.assertGreater(round(10.0 * avg_solibs_added_per_event), 10)

>From 60671ecc918692bba6d937bc7590eae55fd20514 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sat, 8 Jun 2024 12:53:06 +0400
Subject: [PATCH 3/4] Added own so modules.

---
 .../target-new-solib-notifications/Makefile   | 26 +++--
 .../TestModuleLoadedNotifys.py| 53 ---
 .../target-new-solib-notifications/a.cpp  |  7 +++
 .../target-new-solib-notifications/b.cpp  |  5 ++
 .../target-new-solib-notifications/c.cpp  |  1 +
 .../target-new-solib-notifications/d.cpp  |  5 ++
 .../target-new-solib-notifications/main.cpp   | 22 +---
 7 files changed, 102 insertions(+), 17 deletions(-)
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/a.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/b.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/c.cpp
 create mode 100644 
lldb/test/API/functionalities/target-new-solib-notifications/d.cpp

diff --git 
a/lldb/test/API/functionalities/target-new-solib-notifications/Makefile 
b/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
index 8b20bcb05..50169c0ae1b80 100644
--- a/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
+++ b/lldb/test/API/functionalities/target-new-solib-notifications/Makefile
@@ -1,3 +1,23 @@
-CXX_SOURCES := main.cpp
-
-include Makefile.rules
+CXX_SOURCES := main.cpp
+LD_EXTRAS := -L. -lloadunload_d -lloadunload_c -lloadunload_a -lloadunload_b
+
+a.out: lib_b lib_a lib_c lib_d
+
+include Makefile.rules
+
+lib_a: lib_b
+   $(MAKE

[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-10 Thread Dmitry Vasilyev via lldb-commits


@@ -9,22 +9,51 @@
 from lldbsuite.test import lldbutil
 
 
+@skipUnlessPlatform(["linux"] + lldbplatformutil.getDarwinOSTriples())
 class ModuleLoadedNotifysTestCase(TestBase):
 NO_DEBUG_INFO_TESTCASE = True
 
 # At least DynamicLoaderDarwin and DynamicLoaderPOSIXDYLD should batch up
 # notifications about newly added/removed libraries.  Other DynamicLoaders 
may
 # not be written this way.
-@skipUnlessPlatform(["linux"] + lldbplatformutil.getDarwinOSTriples())
 def setUp(self):
 # Call super's setUp().
 TestBase.setUp(self)
 # Find the line number to break inside main().
 self.line = line_number("main.cpp", "// breakpoint")
 
+def setup_test(self, solibs):
+if lldb.remote_platform:
+path = lldb.remote_platform.GetWorkingDirectory()
+for f in solibs:
+lldbutil.install_to_target(self, self.getBuildArtifact(f))
+else:
+path = self.getBuildDir()
+if self.dylibPath in os.environ:
+sep = self.platformContext.shlib_path_separator
+path = os.environ[self.dylibPath] + sep + path
+self.runCmd(
+"settings append target.env-vars '{}={}'".format(self.dylibPath, 
path)
+)
+self.default_path = path
+
 def test_launch_notifications(self):
 """Test that lldb broadcasts newly loaded libraries in batches."""
+
+ext = "so"
+if self.platformIsDarwin():
+ext = "dylib"

slydiman wrote:

Done.

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-10 Thread Dmitry Vasilyev via lldb-commits


@@ -0,0 +1,7 @@
+extern "C" int b_function();
+
+int a_init() { return 234; }
+
+int a_global = a_init();

slydiman wrote:

Done.

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-10 Thread Dmitry Vasilyev via lldb-commits


@@ -1,3 +1,23 @@
-CXX_SOURCES := main.cpp
-
-include Makefile.rules
+CXX_SOURCES := main.cpp
+LD_EXTRAS := -L. -lloadunload_d -lloadunload_c -lloadunload_a -lloadunload_b

slydiman wrote:

Done.

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-10 Thread Dmitry Vasilyev via lldb-commits


@@ -115,9 +151,10 @@ def test_launch_notifications(self):
 # binaries in batches.  Check that we got back more than 1 solib per 
event.
 # In practice on Darwin today, we get back two events for a do-nothing 
c
 # program: a.out and dyld, and then all the rest of the system 
libraries.
-# On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
-
-avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+# On Linux we get events for ld.so, [vdso], the binary and then all 
libraries,
+# but the different configurations could load a different number of 
.so modules
+# per event.
+self.assertGreaterEqual(
+len(set(max_solib_chunk_per_event).intersection(expected_solibs)),
+len(expected_solibs),

slydiman wrote:

Done.

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-10 Thread Dmitry Vasilyev via lldb-commits


@@ -118,6 +118,6 @@ def test_launch_notifications(self):
 # On Linux we get events for ld.so, [vdso], the binary and then all 
libraries.
 
 avg_solibs_added_per_event = round(
-float(total_solibs_added) / float(total_modules_added_events)
+10.0 * float(total_solibs_added) / 
float(total_modules_added_events)

slydiman wrote:

I just checked the documentation for assertGreater() trying to figure out the 
purpose of round() usage in the original code. But it does not matter anymore, 
since the patch has been significantly refactored.

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-10 Thread Pavel Labath via lldb-commits

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

Thanks.

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


[Lldb-commits] [lldb] [lldb] Fix TestModuleLoadedNotifys API test to work correctly on most of Linux targets (PR #94672)

2024-06-10 Thread Dmitry Vasilyev via lldb-commits

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