[Lldb-commits] [lldb] [lldb] Include `` for `system_clock` (PR #118059)

2024-11-29 Thread A. Jiang via lldb-commits

https://github.com/frederick-vs-ja approved this pull request.

LGTM!

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


[Lldb-commits] [lldb] [lldb] Include `` for `system_clock` and `now` (PR #118059)

2024-11-29 Thread Lily Wang via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Include `` for `system_clock` (PR #118059)

2024-11-29 Thread Lily Wang via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Include `` for `system_clock` and `now` (PR #118059)

2024-11-29 Thread David Spickett via lldb-commits

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

This is what I would have assumed reading 
https://en.cppreference.com/w/cpp/chrono, so LGTM. Thank you for the proactive 
fix!

Given that this has built on other platforms without issue, is it worth 
checking if libcxx also has this quirk?

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


[Lldb-commits] [lldb] [lldb] fix fd leak during lldb testsuite (PR #118093)

2024-11-29 Thread via lldb-commits

https://github.com/dlav-sc created 
https://github.com/llvm/llvm-project/pull/118093

During lldb testing dotest.py opens files to dump testcase results, but doesn't 
close them.

This patch makes neccessary changes to fix the file descriptors leak.

>From e449a10882233c52d9ae8602376489340afdf6e9 Mon Sep 17 00:00:00 2001
From: Daniil Avdeev 
Date: Tue, 12 Nov 2024 14:25:09 +
Subject: [PATCH] [lldb] fix fd leak during lldb testsuite

During lldb testing dotest.py opens files to dump testcase results, but
doesn't close them.

This patch makes neccessary changes to fix the file descriptors leak.
---
 .../Python/lldbsuite/test/lldbtest.py | 19 ++-
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 8884ef5933ada8..1338d16a9171e2 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -865,13 +865,9 @@ def setUp(self):
 session_file = self.getLogBasenameForCurrentTest() + ".log"
 self.log_files.append(session_file)
 
-# Python 3 doesn't support unbuffered I/O in text mode.  Open buffered.
-self.session = encoded_file.open(session_file, "utf-8", mode="w")
-
 # Optimistically set __errored__, __failed__, __expected__ to False
 # initially.  If the test errored/failed, the session info
-# (self.session) is then dumped into a session specific file for
-# diagnosis.
+# is then dumped into a session specific file for diagnosis.
 self.__cleanup_errored__ = False
 self.__errored__ = False
 self.__failed__ = False
@@ -1235,20 +1231,25 @@ def dumpSessionInfo(self):
 else:
 prefix = "Success"
 
+session_file = self.getLogBasenameForCurrentTest() + ".log"
+
+# Python 3 doesn't support unbuffered I/O in text mode.  Open buffered.
+session = encoded_file.open(session_file, "utf-8", mode="w")
+
 if not self.__unexpected__ and not self.__skipped__:
 for test, traceback in pairs:
 if test is self:
-print(traceback, file=self.session)
+print(traceback, file=session)
 
 import datetime
 
 print(
 "Session info generated @",
 datetime.datetime.now().ctime(),
-file=self.session,
+file=session,
 )
-self.session.close()
-del self.session
+session.close()
+del session
 
 # process the log files
 if prefix != "Success" or lldbtest_config.log_success:

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


[Lldb-commits] [lldb] [lldb] fix fd leak during lldb testsuite (PR #118093)

2024-11-29 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (dlav-sc)


Changes

During lldb testing dotest.py opens files to dump testcase results, but doesn't 
close them.

This patch makes neccessary changes to fix the file descriptors leak.

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


1 Files Affected:

- (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+10-9) 


``diff
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 8884ef5933ada8..1338d16a9171e2 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -865,13 +865,9 @@ def setUp(self):
 session_file = self.getLogBasenameForCurrentTest() + ".log"
 self.log_files.append(session_file)
 
-# Python 3 doesn't support unbuffered I/O in text mode.  Open buffered.
-self.session = encoded_file.open(session_file, "utf-8", mode="w")
-
 # Optimistically set __errored__, __failed__, __expected__ to False
 # initially.  If the test errored/failed, the session info
-# (self.session) is then dumped into a session specific file for
-# diagnosis.
+# is then dumped into a session specific file for diagnosis.
 self.__cleanup_errored__ = False
 self.__errored__ = False
 self.__failed__ = False
@@ -1235,20 +1231,25 @@ def dumpSessionInfo(self):
 else:
 prefix = "Success"
 
+session_file = self.getLogBasenameForCurrentTest() + ".log"
+
+# Python 3 doesn't support unbuffered I/O in text mode.  Open buffered.
+session = encoded_file.open(session_file, "utf-8", mode="w")
+
 if not self.__unexpected__ and not self.__skipped__:
 for test, traceback in pairs:
 if test is self:
-print(traceback, file=self.session)
+print(traceback, file=session)
 
 import datetime
 
 print(
 "Session info generated @",
 datetime.datetime.now().ctime(),
-file=self.session,
+file=session,
 )
-self.session.close()
-del self.session
+session.close()
+del session
 
 # process the log files
 if prefix != "Success" or lldbtest_config.log_success:

``




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


[Lldb-commits] [lldb] [lldb] rename fooSynthProvider module (PR #118094)

2024-11-29 Thread via lldb-commits

https://github.com/dlav-sc created 
https://github.com/llvm/llvm-project/pull/118094

Currently SyntheticCappingTestCase fails with
```
AttributeError: type object 'fooSynthProvider' has no attribute
'reset_max_num_children_max'
```

The source of the issue is that lldb during PythonSynthDataFormatterTestCase 
imports fooSynthProvider.py module and after that during 
SyntheticCappingTestCase tries to import another module with the same name, 
finds out that it already has the module and as a result, 
SyntheticCappingTestCase uses the old module instead the right one.

I've just renamed the module that SyntheticCappingTestCase is supposed to use 
to avoid such collision.

>From 11d1f52ea2bc578c9bd15646d653f5e2a1626750 Mon Sep 17 00:00:00 2001
From: Daniil Avdeev 
Date: Wed, 13 Nov 2024 10:10:06 +
Subject: [PATCH] [lldb] rename fooSynthProvider module

Currently SyntheticCappingTestCase fails with
```
AttributeError: type object 'fooSynthProvider' has no attribute
'reset_max_num_children_max'
```

The source of the issue is that lldb during PythonSynthDataFormatterTestCase
imports fooSynthProvider.py module and after that during 
SyntheticCappingTestCase
tries to import another module with the same name, finds out that it already has
the module with this name and uses it instead. As a result, 
SyntheticCappingTestCase
uses a wrong module.

I've just renamed a module that SyntheticCappingTestCase is supposed to use
to avoid collision.
---
 ...ooSynthProvider.py => SynthcappingSynthProvider.py} | 10 +-
 .../synthcapping/TestSyntheticCapping.py   | 10 +-
 2 files changed, 10 insertions(+), 10 deletions(-)
 rename 
lldb/test/API/functionalities/data-formatter/synthcapping/{fooSynthProvider.py 
=> SynthcappingSynthProvider.py} (75%)

diff --git 
a/lldb/test/API/functionalities/data-formatter/synthcapping/fooSynthProvider.py 
b/lldb/test/API/functionalities/data-formatter/synthcapping/SynthcappingSynthProvider.py
similarity index 75%
rename from 
lldb/test/API/functionalities/data-formatter/synthcapping/fooSynthProvider.py
rename to 
lldb/test/API/functionalities/data-formatter/synthcapping/SynthcappingSynthProvider.py
index 5ea392ac882998..e61864d6329aa0 100644
--- 
a/lldb/test/API/functionalities/data-formatter/synthcapping/fooSynthProvider.py
+++ 
b/lldb/test/API/functionalities/data-formatter/synthcapping/SynthcappingSynthProvider.py
@@ -1,15 +1,15 @@
 import lldb
 
 
-class fooSynthProvider:
+class SynthcappingSynthProvider:
 # For testing purposes, we'll keep track of the maximum value of
 # max_num_children we've been called with.
 MAX_NUM_CHILDREN_MAX = 0
 
 @classmethod
 def reset_max_num_children_max(cls):
-old_value = fooSynthProvider.MAX_NUM_CHILDREN_MAX
-fooSynthProvider.MAX_NUM_CHILDREN_MAX = 0
+old_value = SynthcappingSynthProvider.MAX_NUM_CHILDREN_MAX
+SynthcappingSynthProvider.MAX_NUM_CHILDREN_MAX = 0
 return old_value
 
 def __init__(self, valobj, dict):
@@ -17,8 +17,8 @@ def __init__(self, valobj, dict):
 self.int_type = valobj.GetType().GetBasicType(lldb.eBasicTypeInt)
 
 def num_children(self, max_num_children):
-fooSynthProvider.MAX_NUM_CHILDREN_MAX = max(
-fooSynthProvider.MAX_NUM_CHILDREN_MAX, max_num_children
+SynthcappingSynthProvider.MAX_NUM_CHILDREN_MAX = max(
+SynthcappingSynthProvider.MAX_NUM_CHILDREN_MAX, max_num_children
 )
 return 3
 
diff --git 
a/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
 
b/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
index 9ca232abefa035..4ce14f5b6cab04 100644
--- 
a/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
+++ 
b/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
@@ -49,8 +49,8 @@ def cleanup():
 self.addTearDownHook(cleanup)
 
 # set up the synthetic children provider
-self.runCmd("script from fooSynthProvider import *")
-self.runCmd("type synth add -l fooSynthProvider foo")
+self.runCmd("script from SynthcappingSynthProvider import *")
+self.runCmd("type synth add -l SynthcappingSynthProvider foo")
 
 # note that the value of fake_a depends on target byte order
 if process.GetByteOrder() == lldb.eByteOrderLittle:
@@ -71,7 +71,7 @@ def cleanup():
 # num_children() should be called with at most max_num_children=257
 # (target.max-children-count + 1)
 self.expect(
-"script fooSynthProvider.reset_max_num_children_max()", 
substrs=["257"]
+"script SynthcappingSynthProvider.reset_max_num_children_max()", 
substrs=["257"]
 )
 
 # check that capping works
@@ -86,7 +86,7 @@ def cleanup():
 ],
 )
 self.expect(
-"script fooSynthProvider.reset_max_num_children_max()", 
substrs=["3"]
+"

[Lldb-commits] [lldb] [lldb] rename fooSynthProvider module (PR #118094)

2024-11-29 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (dlav-sc)


Changes

Currently SyntheticCappingTestCase fails with
```
AttributeError: type object 'fooSynthProvider' has no attribute
'reset_max_num_children_max'
```

The source of the issue is that lldb during PythonSynthDataFormatterTestCase 
imports fooSynthProvider.py module and after that during 
SyntheticCappingTestCase tries to import another module with the same name, 
finds out that it already has the module and as a result, 
SyntheticCappingTestCase uses the old module instead the right one.

I've just renamed the module that SyntheticCappingTestCase is supposed to use 
to avoid such collision.

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


2 Files Affected:

- (renamed) 
lldb/test/API/functionalities/data-formatter/synthcapping/SynthcappingSynthProvider.py
 (+5-5) 
- (modified) 
lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
 (+5-5) 


``diff
diff --git 
a/lldb/test/API/functionalities/data-formatter/synthcapping/fooSynthProvider.py 
b/lldb/test/API/functionalities/data-formatter/synthcapping/SynthcappingSynthProvider.py
similarity index 75%
rename from 
lldb/test/API/functionalities/data-formatter/synthcapping/fooSynthProvider.py
rename to 
lldb/test/API/functionalities/data-formatter/synthcapping/SynthcappingSynthProvider.py
index 5ea392ac882998..e61864d6329aa0 100644
--- 
a/lldb/test/API/functionalities/data-formatter/synthcapping/fooSynthProvider.py
+++ 
b/lldb/test/API/functionalities/data-formatter/synthcapping/SynthcappingSynthProvider.py
@@ -1,15 +1,15 @@
 import lldb
 
 
-class fooSynthProvider:
+class SynthcappingSynthProvider:
 # For testing purposes, we'll keep track of the maximum value of
 # max_num_children we've been called with.
 MAX_NUM_CHILDREN_MAX = 0
 
 @classmethod
 def reset_max_num_children_max(cls):
-old_value = fooSynthProvider.MAX_NUM_CHILDREN_MAX
-fooSynthProvider.MAX_NUM_CHILDREN_MAX = 0
+old_value = SynthcappingSynthProvider.MAX_NUM_CHILDREN_MAX
+SynthcappingSynthProvider.MAX_NUM_CHILDREN_MAX = 0
 return old_value
 
 def __init__(self, valobj, dict):
@@ -17,8 +17,8 @@ def __init__(self, valobj, dict):
 self.int_type = valobj.GetType().GetBasicType(lldb.eBasicTypeInt)
 
 def num_children(self, max_num_children):
-fooSynthProvider.MAX_NUM_CHILDREN_MAX = max(
-fooSynthProvider.MAX_NUM_CHILDREN_MAX, max_num_children
+SynthcappingSynthProvider.MAX_NUM_CHILDREN_MAX = max(
+SynthcappingSynthProvider.MAX_NUM_CHILDREN_MAX, max_num_children
 )
 return 3
 
diff --git 
a/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
 
b/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
index 9ca232abefa035..4ce14f5b6cab04 100644
--- 
a/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
+++ 
b/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
@@ -49,8 +49,8 @@ def cleanup():
 self.addTearDownHook(cleanup)
 
 # set up the synthetic children provider
-self.runCmd("script from fooSynthProvider import *")
-self.runCmd("type synth add -l fooSynthProvider foo")
+self.runCmd("script from SynthcappingSynthProvider import *")
+self.runCmd("type synth add -l SynthcappingSynthProvider foo")
 
 # note that the value of fake_a depends on target byte order
 if process.GetByteOrder() == lldb.eByteOrderLittle:
@@ -71,7 +71,7 @@ def cleanup():
 # num_children() should be called with at most max_num_children=257
 # (target.max-children-count + 1)
 self.expect(
-"script fooSynthProvider.reset_max_num_children_max()", 
substrs=["257"]
+"script SynthcappingSynthProvider.reset_max_num_children_max()", 
substrs=["257"]
 )
 
 # check that capping works
@@ -86,7 +86,7 @@ def cleanup():
 ],
 )
 self.expect(
-"script fooSynthProvider.reset_max_num_children_max()", 
substrs=["3"]
+"script SynthcappingSynthProvider.reset_max_num_children_max()", 
substrs=["3"]
 )
 
 self.expect("frame variable f00_1", matching=False, substrs=["r = 34"])
@@ -95,5 +95,5 @@ def cleanup():
 
 self.expect("frame variable f00_1", matching=True, substrs=["r = 34"])
 self.expect(
-"script fooSynthProvider.reset_max_num_children_max()", 
substrs=["257"]
+"script SynthcappingSynthProvider.reset_max_num_children_max()", 
substrs=["257"]
 )

``




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


[Lldb-commits] [lldb] [lldb] fix SourceManagerTestCase freeze (PR #118095)

2024-11-29 Thread via lldb-commits

https://github.com/dlav-sc created 
https://github.com/llvm/llvm-project/pull/118095

Currently lldb testsuite requires some interactive input:

```
test_artificial_source_location (TestSourceManager.SourceManagerTestCase)
There is a running process, kill it and restart?: [Y/n]
```

This patch sets lldb auto-confirm flag to true before SourceManagerTestCase 
start, so the test doesn't freeze now.

>From 701bb371f289620bb9c0da7de7d7bae8a09293b9 Mon Sep 17 00:00:00 2001
From: Daniil Avdeev 
Date: Mon, 29 Jul 2024 12:14:22 +
Subject: [PATCH] [lldb] fix SourceManagerTestCase freeze

Currently lldb testsuite requires some interactive input:
```
test_artificial_source_location (TestSourceManager.SourceManagerTestCase)
There is a running process, kill it and restart?: [Y/n]
```

This patch sets lldb auto-confirm flag to true before SourceManagerTestCase
start, so this test doesn't freeze now.
---
 lldb/test/API/source-manager/TestSourceManager.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lldb/test/API/source-manager/TestSourceManager.py 
b/lldb/test/API/source-manager/TestSourceManager.py
index ad7c85aac70eaf..6c15f69118a194 100644
--- a/lldb/test/API/source-manager/TestSourceManager.py
+++ b/lldb/test/API/source-manager/TestSourceManager.py
@@ -37,6 +37,9 @@ def setUp(self):
 # Find the line number to break inside main().
 self.file = self.getBuildArtifact("main-copy.c")
 self.line = line_number("main.c", "// Set break point at this line.")
+# disable "There is a running process, kill it and restart?" prompt
+self.runCmd("settings set auto-confirm true")
+self.addTearDownHook(lambda: self.runCmd("settings clear 
auto-confirm"))
 
 def modify_content(self):
 # Read the main.c file content.

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


[Lldb-commits] [lldb] [lldb] fix SourceManagerTestCase freeze (PR #118095)

2024-11-29 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (dlav-sc)


Changes

Currently lldb testsuite requires some interactive input:

```
test_artificial_source_location (TestSourceManager.SourceManagerTestCase)
There is a running process, kill it and restart?: [Y/n]
```

This patch sets lldb auto-confirm flag to true before SourceManagerTestCase 
start, so the test doesn't freeze now.

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


1 Files Affected:

- (modified) lldb/test/API/source-manager/TestSourceManager.py (+3) 


``diff
diff --git a/lldb/test/API/source-manager/TestSourceManager.py 
b/lldb/test/API/source-manager/TestSourceManager.py
index ad7c85aac70eaf..6c15f69118a194 100644
--- a/lldb/test/API/source-manager/TestSourceManager.py
+++ b/lldb/test/API/source-manager/TestSourceManager.py
@@ -37,6 +37,9 @@ def setUp(self):
 # Find the line number to break inside main().
 self.file = self.getBuildArtifact("main-copy.c")
 self.line = line_number("main.c", "// Set break point at this line.")
+# disable "There is a running process, kill it and restart?" prompt
+self.runCmd("settings set auto-confirm true")
+self.addTearDownHook(lambda: self.runCmd("settings clear 
auto-confirm"))
 
 def modify_content(self):
 # Read the main.c file content.

``




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


[Lldb-commits] [lldb] [lldb] rename fooSynthProvider module (PR #118094)

2024-11-29 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 
fedb9fdb98314ff0ddff065dbd6ef8b2b7e6ec96...11d1f52ea2bc578c9bd15646d653f5e2a1626750
 
lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py
 
lldb/test/API/functionalities/data-formatter/synthcapping/SynthcappingSynthProvider.py
``





View the diff from darker here.


``diff
--- TestSyntheticCapping.py 2024-11-29 13:43:46.00 +
+++ TestSyntheticCapping.py 2024-11-29 13:50:31.208235 +
@@ -69,11 +69,12 @@
 ],
 )
 # num_children() should be called with at most max_num_children=257
 # (target.max-children-count + 1)
 self.expect(
-"script SynthcappingSynthProvider.reset_max_num_children_max()", 
substrs=["257"]
+"script SynthcappingSynthProvider.reset_max_num_children_max()",
+substrs=["257"],
 )
 
 # check that capping works
 self.runCmd("settings set target.max-children-count 2", check=False)
 
@@ -84,16 +85,18 @@
 "fake_a = %d" % fake_a_val,
 "...",
 ],
 )
 self.expect(
-"script SynthcappingSynthProvider.reset_max_num_children_max()", 
substrs=["3"]
+"script SynthcappingSynthProvider.reset_max_num_children_max()",
+substrs=["3"],
 )
 
 self.expect("frame variable f00_1", matching=False, substrs=["r = 34"])
 
 self.runCmd("settings set target.max-children-count 256", check=False)
 
 self.expect("frame variable f00_1", matching=True, substrs=["r = 34"])
 self.expect(
-"script SynthcappingSynthProvider.reset_max_num_children_max()", 
substrs=["257"]
+"script SynthcappingSynthProvider.reset_max_num_children_max()",
+substrs=["257"],
 )

``




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


[Lldb-commits] [lldb] [lldb] fix SourceManagerTestCase freeze (PR #118095)

2024-11-29 Thread David Spickett via lldb-commits

DavidSpickett wrote:

On what platform are you seeing this problem? None of Linaro's bots have an 
issue with the test.

Is it because you're using remote debugging and only in that case it prompts 
for this?

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


[Lldb-commits] [lldb] [lldb] rename fooSynthProvider module (PR #118094)

2024-11-29 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Seems fine but please expand on `Currently SyntheticCappingTestCase fails with` 
to say where it fails. Linaro's bots don't have a problem with this test, so I 
assume you are using a different kind of setup.

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


[Lldb-commits] [lldb] [lldb] fix fd leak during lldb testsuite (PR #118093)

2024-11-29 Thread David Spickett via lldb-commits

DavidSpickett wrote:

It leaks the fds if `dumpSessionInfo` is never called, do I understand 
correctly? If so please add that information to the PR description.

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


[Lldb-commits] [lldb] [lldb] fix fd leak during lldb testsuite (PR #118093)

2024-11-29 Thread via lldb-commits

dlav-sc wrote:

> It leaks the fds if `dumpSessionInfo` is never called

Yeah, `dumpSessionInfo` closes session log file, but looks like 
`dumpSessionInfo` isn't called anywhere. Honestly, I don't understand the 
necessity of the function in that case, maybe we can remove it.

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


[Lldb-commits] [lldb] [lldb] fix fd leak during lldb testsuite (PR #118093)

2024-11-29 Thread David Spickett via lldb-commits

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

Happy for it to be fixed and removed in another PR if it's unused.

Saves us resurrecting a broken function if we do want it back in future.

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


[Lldb-commits] [lldb] [lldb] fix fd leak during lldb testsuite (PR #118093)

2024-11-29 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb] rename fooSynthProvider module (PR #118094)

2024-11-29 Thread via lldb-commits

dlav-sc wrote:

> Seems fine but please expand on `Currently SyntheticCappingTestCase fails 
> with` to say where it fails. 

I can provide the fail log. Looks like lldb firstly runs 
`PythonSynthDataFormatterTestCase` and then `SyntheticCappingTestCase`, but it 
doesn't really matter, because if lldb run the tests in another order, 
`PythonSynthDataFormatterTestCase` would fail with the same problem instead of 
`SyntheticCappingTestCase` I suppose. Also I've tried to run 
`SyntheticCappingTestCase` alone using a filter option of the `dotest.py` 
script and the test passes in that case.

```
==
FAIL: test_with_run_command_dwarf 
(TestSyntheticCapping.SyntheticCappingTestCase.test_with_run_command_dwarf)
  Check for an issue where capping does not work because the Target pointer 
appears to be changing behind our backs.
--
Traceback (most recent call last):
  File 
"/home/daniil/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", 
line 1760, in test_method
return attrvalue(self)
   ^^^
  File 
"/home/daniil/llvm-project/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py",
 line 73, in test_with_run_command
self.expect(
  File 
"/home/daniil/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", 
line 2466, in expect
self.fail(log_msg)
AssertionError: Ran command:
"script fooSynthProvider.fooSynthProvider.reset_max_num_children_max()"
Got output:
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: type object 'fooSynthProvider' has no attribute 
'reset_max_num_children_max'
Expecting sub string: "257" (was not found)
==
FAIL: test_with_run_command_dwo 
(TestSyntheticCapping.SyntheticCappingTestCase.test_with_run_command_dwo)
  Check for an issue where capping does not work because the Target pointer 
appears to be changing behind our backs.
--
Traceback (most recent call last):
  File 
"/home/daniil/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", 
line 1760, in test_method
return attrvalue(self)
   ^^^
  File 
"/home/daniil/llvm-project/lldb/test/API/functionalities/data-formatter/synthcapping/TestSyntheticCapping.py",
 line 73, in test_with_run_command
self.expect(
  File 
"/home/daniil/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py", 
line 2466, in expect
self.fail(log_msg)
AssertionError: Ran command:
"script fooSynthProvider.fooSynthProvider.reset_max_num_children_max()"
Got output:
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: type object 'fooSynthProvider' has no attribute 
'reset_max_num_children_max'
Expecting sub string: "257" (was not found)
```

> I assume you are using a different kind of setup

Maybe it's true, I've tried to test lldb on riscv using dotest.py with remote 
debugging options.

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


[Lldb-commits] [lldb] [lldb][AIX] HostInfoAIX Support (PR #117906)

2024-11-29 Thread David Spickett via lldb-commits


@@ -0,0 +1,213 @@
+//===-- HostInfoAIX.cpp -===//
+//
+// 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
+//
+//===--===//
+
+#include "lldb/Host/aix/HostInfoAIX.h"
+#include "lldb/Host/Config.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+
+#include "llvm/Support/Threading.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+using namespace lldb_private;
+
+namespace {
+struct HostInfoAIXFields {
+  llvm::once_flag m_distribution_once_flag;
+  std::string m_distribution_id;
+  llvm::once_flag m_os_version_once_flag;
+  llvm::VersionTuple m_os_version;
+};
+} // namespace
+
+static HostInfoAIXFields *g_fields = nullptr;
+
+void HostInfoAIX::Initialize(SharedLibraryDirectoryHelper *helper) {
+  HostInfoPosix::Initialize(helper);
+
+  g_fields = new HostInfoAIXFields();
+}
+
+void HostInfoAIX::Terminate() {
+  assert(g_fields && "Missing call to Initialize?");
+  delete g_fields;
+  g_fields = nullptr;
+  HostInfoBase::Terminate();
+}
+
+llvm::VersionTuple HostInfoAIX::GetOSVersion() {
+  assert(g_fields && "Missing call to Initialize?");
+  llvm::call_once(g_fields->m_os_version_once_flag, []() {
+struct utsname un;
+if (uname(&un) != 0)
+  return;
+
+llvm::StringRef release = un.release;
+// The kernel release string can include a lot of stuff (e.g.
+// 4.9.0-6-amd64). We're only interested in the numbered prefix.
+release = release.substr(0, release.find_first_not_of("0123456789."));
+g_fields->m_os_version.tryParse(release);
+  });
+
+  return g_fields->m_os_version;
+}
+
+std::optional HostInfoAIX::GetOSBuildString() {
+  struct utsname un;
+  ::memset(&un, 0, sizeof(utsname));
+
+  if (uname(&un) < 0)
+return std::nullopt;
+
+  return std::string(un.release);
+}
+
+llvm::StringRef HostInfoAIX::GetDistributionId() {
+  assert(g_fields && "Missing call to Initialize?");
+  // Try to run 'lbs_release -i', and use that response for the distribution
+  // id.
+  llvm::call_once(g_fields->m_distribution_once_flag, []() {
+Log *log = GetLog(LLDBLog::Host);
+LLDB_LOGF(log, "attempting to determine AIX distribution...");
+
+// check if the lsb_release command exists at one of the following paths
+const char *const exe_paths[] = {"/bin/lsb_release",
+ "/usr/bin/lsb_release"};
+
+for (size_t exe_index = 0;
+ exe_index < sizeof(exe_paths) / sizeof(exe_paths[0]); ++exe_index) {
+  const char *const get_distribution_info_exe = exe_paths[exe_index];
+  if (access(get_distribution_info_exe, F_OK)) {
+// this exe doesn't exist, move on to next exe
+LLDB_LOGF(log, "executable doesn't exist: %s",
+  get_distribution_info_exe);
+continue;
+  }
+
+  // execute the distribution-retrieval command, read output
+  std::string get_distribution_id_command(get_distribution_info_exe);
+  get_distribution_id_command += " -i";
+
+  FILE *file = popen(get_distribution_id_command.c_str(), "r");
+  if (!file) {
+LLDB_LOGF(log,
+  "failed to run command: \"%s\", cannot retrieve "
+  "platform information",
+  get_distribution_id_command.c_str());
+break;
+  }
+
+  // retrieve the distribution id string.
+  char distribution_id[256] = {'\0'};
+  if (fgets(distribution_id, sizeof(distribution_id) - 1, file) !=
+  nullptr) {
+LLDB_LOGF(log, "distribution id command returned \"%s\"",
+  distribution_id);
+
+const char *const distributor_id_key = "Distributor ID:\t";
+if (strstr(distribution_id, distributor_id_key)) {
+  // strip newlines
+  std::string id_string(distribution_id + strlen(distributor_id_key));
+  llvm::erase(id_string, '\n');
+
+  // lower case it and convert whitespace to underscores
+  std::transform(
+  id_string.begin(), id_string.end(), id_string.begin(),
+  [](char ch) { return tolower(isspace(ch) ? '_' : ch); });
+
+  g_fields->m_distribution_id = id_string;
+  LLDB_LOGF(log, "distribution id set to \"%s\"",
+g_fields->m_distribution_id.c_str());
+} else {
+  LLDB_LOGF(log, "failed to find \"%s\" field in \"%s\"",
+distributor_id_key, distribution_id);
+}
+  } else {
+LLDB_LOGF(log,
+  "failed to retrieve distribution id, \"%s\" returned no"
+  " lines",
+  get_distribution_id_command.c_str());
+  }
+
+  // clean up the file
+  p

[Lldb-commits] [lldb] [lldb][AIX] HostInfoAIX Support (PR #117906)

2024-11-29 Thread David Spickett via lldb-commits


@@ -0,0 +1,213 @@
+//===-- HostInfoAIX.cpp -===//
+//
+// 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
+//
+//===--===//
+
+#include "lldb/Host/aix/HostInfoAIX.h"
+#include "lldb/Host/Config.h"
+#include "lldb/Host/FileSystem.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+
+#include "llvm/Support/Threading.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+using namespace lldb_private;
+
+namespace {
+struct HostInfoAIXFields {
+  llvm::once_flag m_distribution_once_flag;
+  std::string m_distribution_id;
+  llvm::once_flag m_os_version_once_flag;
+  llvm::VersionTuple m_os_version;
+};
+} // namespace
+
+static HostInfoAIXFields *g_fields = nullptr;
+
+void HostInfoAIX::Initialize(SharedLibraryDirectoryHelper *helper) {
+  HostInfoPosix::Initialize(helper);
+
+  g_fields = new HostInfoAIXFields();
+}
+
+void HostInfoAIX::Terminate() {
+  assert(g_fields && "Missing call to Initialize?");
+  delete g_fields;
+  g_fields = nullptr;
+  HostInfoBase::Terminate();
+}
+
+llvm::VersionTuple HostInfoAIX::GetOSVersion() {
+  assert(g_fields && "Missing call to Initialize?");
+  llvm::call_once(g_fields->m_os_version_once_flag, []() {
+struct utsname un;
+if (uname(&un) != 0)
+  return;
+
+llvm::StringRef release = un.release;
+// The kernel release string can include a lot of stuff (e.g.
+// 4.9.0-6-amd64). We're only interested in the numbered prefix.
+release = release.substr(0, release.find_first_not_of("0123456789."));
+g_fields->m_os_version.tryParse(release);
+  });
+
+  return g_fields->m_os_version;
+}
+
+std::optional HostInfoAIX::GetOSBuildString() {
+  struct utsname un;
+  ::memset(&un, 0, sizeof(utsname));
+
+  if (uname(&un) < 0)
+return std::nullopt;
+
+  return std::string(un.release);
+}
+
+llvm::StringRef HostInfoAIX::GetDistributionId() {
+  assert(g_fields && "Missing call to Initialize?");
+  // Try to run 'lbs_release -i', and use that response for the distribution
+  // id.
+  llvm::call_once(g_fields->m_distribution_once_flag, []() {
+Log *log = GetLog(LLDBLog::Host);
+LLDB_LOGF(log, "attempting to determine AIX distribution...");
+
+// check if the lsb_release command exists at one of the following paths
+const char *const exe_paths[] = {"/bin/lsb_release",
+ "/usr/bin/lsb_release"};
+
+for (size_t exe_index = 0;
+ exe_index < sizeof(exe_paths) / sizeof(exe_paths[0]); ++exe_index) {
+  const char *const get_distribution_info_exe = exe_paths[exe_index];
+  if (access(get_distribution_info_exe, F_OK)) {
+// this exe doesn't exist, move on to next exe
+LLDB_LOGF(log, "executable doesn't exist: %s",
+  get_distribution_info_exe);
+continue;
+  }
+
+  // execute the distribution-retrieval command, read output
+  std::string get_distribution_id_command(get_distribution_info_exe);
+  get_distribution_id_command += " -i";
+
+  FILE *file = popen(get_distribution_id_command.c_str(), "r");
+  if (!file) {
+LLDB_LOGF(log,
+  "failed to run command: \"%s\", cannot retrieve "
+  "platform information",
+  get_distribution_id_command.c_str());
+break;
+  }
+
+  // retrieve the distribution id string.
+  char distribution_id[256] = {'\0'};
+  if (fgets(distribution_id, sizeof(distribution_id) - 1, file) !=
+  nullptr) {
+LLDB_LOGF(log, "distribution id command returned \"%s\"",
+  distribution_id);
+
+const char *const distributor_id_key = "Distributor ID:\t";
+if (strstr(distribution_id, distributor_id_key)) {
+  // strip newlines
+  std::string id_string(distribution_id + strlen(distributor_id_key));
+  llvm::erase(id_string, '\n');
+
+  // lower case it and convert whitespace to underscores
+  std::transform(
+  id_string.begin(), id_string.end(), id_string.begin(),
+  [](char ch) { return tolower(isspace(ch) ? '_' : ch); });
+
+  g_fields->m_distribution_id = id_string;
+  LLDB_LOGF(log, "distribution id set to \"%s\"",
+g_fields->m_distribution_id.c_str());
+} else {
+  LLDB_LOGF(log, "failed to find \"%s\" field in \"%s\"",
+distributor_id_key, distribution_id);
+}
+  } else {
+LLDB_LOGF(log,
+  "failed to retrieve distribution id, \"%s\" returned no"
+  " lines",
+  get_distribution_id_command.c_str());
+  }
+
+  // clean up the file
+  p

[Lldb-commits] [lldb] [lldb] fix SourceManagerTestCase freeze (PR #118095)

2024-11-29 Thread via lldb-commits

dlav-sc wrote:

> On what platform are you seeing this problem?

I've encountered with the problem using remote debugging at first, but then I 
was able to reproduce it on x86 host platform with command looks like this (I 
don't remember exactly):
```
python3 lldb/test/API/dotest.py -A x86-64 -C build/bin/clang --executable 
build/bin/lldb -f SourceManagerTestCase lldb/test/API
```

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


[Lldb-commits] [lldb] [lldb][AIX] Header Parsing for XCOFF Object File in AIX (PR #116338)

2024-11-29 Thread Dhruv Srivastava via lldb-commits

https://github.com/DhruvSrivastavaX updated 
https://github.com/llvm/llvm-project/pull/116338

>From 0c63800bdcbadcfceed4c9a81305eda7d5a15960 Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava 
Date: Fri, 15 Nov 2024 02:16:31 -0600
Subject: [PATCH 1/5] Added XCOFF Header Parsing

---
 .../ObjectFile/XCOFF/ObjectFileXCOFF.cpp  | 126 +-
 .../ObjectFile/XCOFF/ObjectFileXCOFF.h|  58 
 2 files changed, 181 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp 
b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index 3be900f9a4bc9f..c06ece4347822d 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -81,9 +81,44 @@ ObjectFile *ObjectFileXCOFF::CreateInstance(const 
lldb::ModuleSP &module_sp,
   if (!objfile_up)
 return nullptr;
 
+  // Cache xcoff binary.
+  if (!objfile_up->CreateBinary())
+return nullptr;
+
+  if (!objfile_up->ParseHeader())
+return nullptr;
+
   return objfile_up.release();
 }
 
+bool ObjectFileXCOFF::CreateBinary() {
+  if (m_binary)
+return true;
+
+  Log *log = GetLog(LLDBLog::Object);
+
+  auto binary = llvm::object::XCOFFObjectFile::createObjectFile(
+  llvm::MemoryBufferRef(toStringRef(m_data.GetData()),
+m_file.GetFilename().GetStringRef()),
+  file_magic::xcoff_object_64);
+  if (!binary) {
+LLDB_LOG_ERROR(log, binary.takeError(),
+   "Failed to create binary for file ({1}): {0}", m_file);
+return false;
+  }
+
+  // Make sure we only handle XCOFF format.
+  m_binary =
+  llvm::unique_dyn_cast(std::move(*binary));
+  if (!m_binary)
+return false;
+
+  LLDB_LOG(log, "this = {0}, module = {1} ({2}), file = {3}, binary = {4}",
+   this, GetModule().get(), GetModule()->GetSpecificationDescription(),
+   m_file.GetPath(), m_binary.get());
+  return true;
+}
+
 ObjectFile *ObjectFileXCOFF::CreateMemoryInstance(
 const lldb::ModuleSP &module_sp, WritableDataBufferSP data_sp,
 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) {
@@ -136,13 +171,92 @@ bool ObjectFileXCOFF::MagicBytesMatch(DataBufferSP 
&data_sp,
   return XCOFFHeaderSizeFromMagic(magic) != 0;
 }
 
-bool ObjectFileXCOFF::ParseHeader() { return false; }
+bool ObjectFileXCOFF::ParseHeader() {
+  ModuleSP module_sp(GetModule());
+  if (module_sp) {
+std::lock_guard guard(module_sp->GetMutex());
+lldb::offset_t offset = 0;
+
+if (ParseXCOFFHeader(m_data, &offset, m_xcoff_header)) {
+  m_data.SetAddressByteSize(GetAddressByteSize());
+  if (m_xcoff_header.auxhdrsize > 0)
+ParseXCOFFOptionalHeader(m_data, &offset);
+}
+return true;
+  }
+
+  return false;
+}
+
+bool ObjectFileXCOFF::ParseXCOFFHeader(lldb_private::DataExtractor &data,
+   lldb::offset_t *offset_ptr,
+   xcoff_header_t &xcoff_header) {
+  // FIXME: data.ValidOffsetForDataOfSize
+  xcoff_header.magic = data.GetU16(offset_ptr);
+  xcoff_header.nsects = data.GetU16(offset_ptr);
+  xcoff_header.modtime = data.GetU32(offset_ptr);
+  xcoff_header.symoff = data.GetU64(offset_ptr);
+  xcoff_header.auxhdrsize = data.GetU16(offset_ptr);
+  xcoff_header.flags = data.GetU16(offset_ptr);
+  xcoff_header.nsyms = data.GetU32(offset_ptr);
+  return true;
+}
+
+bool ObjectFileXCOFF::ParseXCOFFOptionalHeader(
+lldb_private::DataExtractor &data, lldb::offset_t *offset_ptr) {
+  lldb::offset_t init_offset = *offset_ptr;
+  // FIXME: data.ValidOffsetForDataOfSize
+  m_xcoff_aux_header.AuxMagic = data.GetU16(offset_ptr);
+  m_xcoff_aux_header.Version = data.GetU16(offset_ptr);
+  m_xcoff_aux_header.ReservedForDebugger = data.GetU32(offset_ptr);
+  m_xcoff_aux_header.TextStartAddr = data.GetU64(offset_ptr);
+  m_xcoff_aux_header.DataStartAddr = data.GetU64(offset_ptr);
+  m_xcoff_aux_header.TOCAnchorAddr = data.GetU64(offset_ptr);
+  m_xcoff_aux_header.SecNumOfEntryPoint = data.GetU16(offset_ptr);
+  m_xcoff_aux_header.SecNumOfText = data.GetU16(offset_ptr);
+  m_xcoff_aux_header.SecNumOfData = data.GetU16(offset_ptr);
+  m_xcoff_aux_header.SecNumOfTOC = data.GetU16(offset_ptr);
+  m_xcoff_aux_header.SecNumOfLoader = data.GetU16(offset_ptr);
+  m_xcoff_aux_header.SecNumOfBSS = data.GetU16(offset_ptr);
+  m_xcoff_aux_header.MaxAlignOfText = data.GetU16(offset_ptr);
+  m_xcoff_aux_header.MaxAlignOfData = data.GetU16(offset_ptr);
+  m_xcoff_aux_header.ModuleType = data.GetU16(offset_ptr);
+  m_xcoff_aux_header.CpuFlag = data.GetU8(offset_ptr);
+  m_xcoff_aux_header.CpuType = data.GetU8(offset_ptr);
+  m_xcoff_aux_header.TextPageSize = data.GetU8(offset_ptr);
+  m_xcoff_aux_header.DataPageSize = data.GetU8(offset_ptr);
+  m_xcoff_aux_header.StackPageSize = data.GetU8(offset_ptr);
+  m_xcoff_aux_header.FlagAndTDataAlignment = data.GetU8(offset_ptr);
+  m_xcoff_aux_header.TextSize = data.GetU64(offset_p

[Lldb-commits] [lldb] [lldb][AIX] Header Parsing for XCOFF Object File in AIX (PR #116338)

2024-11-29 Thread Dhruv Srivastava via lldb-commits

DhruvSrivastavaX wrote:

It is updated now. Please provide your review and merge if everything is good. 
@labath 

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


[Lldb-commits] [lldb] [lldb] Include `` for `system_clock` and `now` (PR #118059)

2024-11-29 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)

2024-11-29 Thread Dhruv Srivastava via lldb-commits

https://github.com/DhruvSrivastavaX created 
https://github.com/llvm/llvm-project/pull/118160

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. https://github.com/llvm/llvm-project/issues/101657
The complete changes for porting are present in this draft PR:
https://github.com/llvm/llvm-project/pull/102601

Added base files for NativeProcess Support for AIX. 
Will be adding further support in consequent incremental PR.

Review Request: @labath @DavidSpickett

>From 03a290e9c748540b69ca6df7fa9c4481f9cdd3d0 Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava 
Date: Sat, 30 Nov 2024 01:14:15 -0600
Subject: [PATCH 1/2] Added base files for NativeProcess for AIX

---
 .../source/Plugins/Process/AIX/CMakeLists.txt |  14 +
 .../Plugins/Process/AIX/NativeProcessAIX.cpp  | 288 ++
 .../Plugins/Process/AIX/NativeProcessAIX.h| 134 
 lldb/source/Plugins/Process/CMakeLists.txt|   3 +
 4 files changed, 439 insertions(+)
 create mode 100644 lldb/source/Plugins/Process/AIX/CMakeLists.txt
 create mode 100644 lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp
 create mode 100644 lldb/source/Plugins/Process/AIX/NativeProcessAIX.h

diff --git a/lldb/source/Plugins/Process/AIX/CMakeLists.txt 
b/lldb/source/Plugins/Process/AIX/CMakeLists.txt
new file mode 100644
index 00..4fabbe93022870
--- /dev/null
+++ b/lldb/source/Plugins/Process/AIX/CMakeLists.txt
@@ -0,0 +1,14 @@
+add_lldb_library(lldbPluginProcessAIX
+  NativeProcessAIX.cpp
+
+  LINK_LIBS
+lldbCore
+lldbHost
+lldbSymbol
+lldbTarget
+lldbUtility
+lldbPluginProcessPOSIX
+lldbPluginProcessUtility
+  LINK_COMPONENTS
+Support
+  )
diff --git a/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp 
b/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp
new file mode 100644
index 00..6661693b2fc02b
--- /dev/null
+++ b/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp
@@ -0,0 +1,288 @@
+//===-- NativeProcessAIX.cpp ===//
+//
+// 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
+//
+//===--===//
+
+#include "NativeProcessAIX.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "NativeThreadAIX.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostProcess.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
+#include "lldb/Host/PseudoTerminal.h"
+#include "lldb/Host/ThreadLauncher.h"
+#include "lldb/Host/common/NativeRegisterContext.h"
+#include "lldb/Host/aix/Ptrace.h"
+#include "lldb/Host/posix/ProcessLauncherPosixFork.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/RegisterValue.h"
+#include "lldb/Utility/State.h"
+#include "lldb/Utility/Status.h"
+#include "lldb/Utility/StringExtractor.h"
+#include "llvm/ADT/ScopeExit.h"
+#include "llvm/Support/Errno.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Threading.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#ifdef __aarch64__
+#include 
+#include 
+#endif
+
+// Support hardware breakpoints in case it has not been defined
+#ifndef TRAP_HWBKPT
+#define TRAP_HWBKPT 4
+#endif
+
+#ifndef HWCAP2_MTE
+#define HWCAP2_MTE (1 << 18)
+#endif
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_aix;
+using namespace llvm;
+
+static constexpr unsigned k_ptrace_word_size = sizeof(void *);
+static_assert(sizeof(long) >= k_ptrace_word_size,
+  "Size of long must be larger than ptrace word size");
+
+// Simple helper function to ensure flags are enabled on the given file
+// descriptor.
+static Status EnsureFDFlags(int fd, int flags) {
+  Status error;
+
+  int status = fcntl(fd, F_GETFL);
+  if (status == -1) {
+error = Status::FromErrno();
+return error;
+  }
+
+  if (fcntl(fd, F_SETFL, status | flags) == -1) {
+error = Status::FromErrno();
+return error;
+  }
+
+  return error;
+}
+
+NativeProcessAIX::Manager::Manager(MainLoop &mainloop)
+: NativeProcessProtocol::Manager(mainloop) {
+  Status status;
+  m_sigchld_handle = mainloop.RegisterSignal(
+  SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, status);
+  assert(m_sigchld_handle && status.Success());
+}
+
+// Public Static Methods
+
+llvm::Expected>
+NativeProcessAIX::Manager::Launch(ProcessLaunchInfo &launch_info,
+Nati

[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)

2024-11-29 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 e874c8fc27bbc0e340691d5b5d01c7a1bd365890 
3462b9263d4f268a89baf4b956b8dc851858fe0a --extensions h,cpp -- 
lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp 
lldb/source/Plugins/Process/AIX/NativeProcessAIX.h
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp 
b/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp
index a8d5448323..28f5623853 100644
--- a/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp
+++ b/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp
@@ -7,16 +7,6 @@
 
//===--===//
 
 #include "NativeProcessAIX.h"
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 #include "NativeThreadAIX.h"
 #include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
 #include "lldb/Host/Host.h"
@@ -33,6 +23,16 @@
 #include "llvm/Support/Errno.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
 
 using namespace lldb;
 using namespace lldb_private;
@@ -74,7 +74,7 @@ NativeProcessAIX::Manager::Manager(MainLoop &mainloop)
 
 llvm::Expected>
 NativeProcessAIX::Manager::Launch(ProcessLaunchInfo &launch_info,
-NativeDelegate &native_delegate) {
+  NativeDelegate &native_delegate) {
   Log *log = GetLog(POSIXLog::Process);
 
   Status status;
@@ -102,13 +102,13 @@ NativeProcessAIX::Manager::Launch(ProcessLaunchInfo 
&launch_info,
 
   ProcessInstanceInfo Info;
   if (!Host::GetProcessInfo(pid, Info)) {
-  return llvm::make_error("Cannot get process architectrue",
-llvm::inconvertibleErrorCode());
-  } 
+return llvm::make_error("Cannot get process architectrue",
+ llvm::inconvertibleErrorCode());
+  }
 
- // Set the architecture to the exe architecture.
-  LLDB_LOG(log, "pid = {0}, detected architecture {1}", pid, 
-  Info.GetArchitecture().GetArchitectureName());
+  // Set the architecture to the exe architecture.
+  LLDB_LOG(log, "pid = {0}, detected architecture {1}", pid,
+   Info.GetArchitecture().GetArchitectureName());
 
   return std::unique_ptr(new NativeProcessAIX(
   pid, launch_info.GetPTY().ReleasePrimaryFileDescriptor(), 
native_delegate,
@@ -117,21 +117,21 @@ NativeProcessAIX::Manager::Launch(ProcessLaunchInfo 
&launch_info,
 
 llvm::Expected>
 NativeProcessAIX::Manager::Attach(
-lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate) { 
+lldb::pid_t pid, NativeProcessProtocol::NativeDelegate &native_delegate) {
   Log *log = GetLog(POSIXLog::Process);
   LLDB_LOG(log, "pid = {0:x}", pid);
 
   ProcessInstanceInfo Info;
   if (!Host::GetProcessInfo(pid, Info)) {
-  return llvm::make_error("Cannot get process architectrue",
-llvm::inconvertibleErrorCode());
-  } 
+return llvm::make_error("Cannot get process architectrue",
+ llvm::inconvertibleErrorCode());
+  }
   auto tids_or = NativeProcessAIX::Attach(pid);
   if (!tids_or)
 return tids_or.takeError();
 
-  return std::unique_ptr(
-  new NativeProcessAIX(pid, -1, native_delegate, Info.GetArchitecture(), 
*this, *tids_or));
+  return std::unique_ptr(new NativeProcessAIX(
+  pid, -1, native_delegate, Info.GetArchitecture(), *this, *tids_or));
 }
 
 NativeProcessAIX::Extension
@@ -144,18 +144,16 @@ NativeProcessAIX::Manager::GetSupportedExtensions() const 
{
   return supported;
 }
 
-void NativeProcessAIX::Manager::SigchldHandler() {
-}
+void NativeProcessAIX::Manager::SigchldHandler() {}
 
-void NativeProcessAIX::Manager::CollectThread(::pid_t tid) {
-}
+void NativeProcessAIX::Manager::CollectThread(::pid_t tid) {}
 
 // Public Instance Methods
 
 NativeProcessAIX::NativeProcessAIX(::pid_t pid, int terminal_fd,
-   NativeDelegate &delegate,
-   const ArchSpec &arch, Manager &manager,
-   llvm::ArrayRef<::pid_t> tids)
+   NativeDelegate &delegate,
+   const ArchSpec &arch, Manager &manager,
+   llvm::ArrayRef<::pid_t> tids)
 : NativeProcessProtocol(pid, terminal_fd, delegate), m_manager(manager),
   m_arch(arch) {
   manager.AddProcess(*this);
@@ -182,15 +180,11 @@ llvm::Expected> 
NativeProcessAIX::Attach(::pid_t pid) {
 }
 
 void NativeProcessAIX::MonitorSIGTRAP(const WaitStatus status,
-  

[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)

2024-11-29 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dhruv Srivastava (DhruvSrivastavaX)


Changes

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. https://github.com/llvm/llvm-project/issues/101657
The complete changes for porting are present in this draft PR:
https://github.com/llvm/llvm-project/pull/102601

Added base files for NativeProcess Support for AIX. 
Will be adding further support in consequent incremental PR.

Review Request: @labath @DavidSpickett

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


4 Files Affected:

- (added) lldb/source/Plugins/Process/AIX/CMakeLists.txt (+14) 
- (added) lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp (+257) 
- (added) lldb/source/Plugins/Process/AIX/NativeProcessAIX.h (+134) 
- (modified) lldb/source/Plugins/Process/CMakeLists.txt (+3) 


``diff
diff --git a/lldb/source/Plugins/Process/AIX/CMakeLists.txt 
b/lldb/source/Plugins/Process/AIX/CMakeLists.txt
new file mode 100644
index 00..4fabbe93022870
--- /dev/null
+++ b/lldb/source/Plugins/Process/AIX/CMakeLists.txt
@@ -0,0 +1,14 @@
+add_lldb_library(lldbPluginProcessAIX
+  NativeProcessAIX.cpp
+
+  LINK_LIBS
+lldbCore
+lldbHost
+lldbSymbol
+lldbTarget
+lldbUtility
+lldbPluginProcessPOSIX
+lldbPluginProcessUtility
+  LINK_COMPONENTS
+Support
+  )
diff --git a/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp 
b/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp
new file mode 100644
index 00..a8d54483239ad2
--- /dev/null
+++ b/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp
@@ -0,0 +1,257 @@
+//===-- NativeProcessAIX.cpp ===//
+//
+// 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
+//
+//===--===//
+
+#include "NativeProcessAIX.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "NativeThreadAIX.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostProcess.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/State.h"
+#include "lldb/Utility/Status.h"
+#include "lldb/Utility/StringExtractor.h"
+#include "llvm/Support/Errno.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_aix;
+using namespace llvm;
+
+static constexpr unsigned k_ptrace_word_size = sizeof(void *);
+static_assert(sizeof(long) >= k_ptrace_word_size,
+  "Size of long must be larger than ptrace word size");
+
+// Simple helper function to ensure flags are enabled on the given file
+// descriptor.
+static Status EnsureFDFlags(int fd, int flags) {
+  Status error;
+
+  int status = fcntl(fd, F_GETFL);
+  if (status == -1) {
+error = Status::FromErrno();
+return error;
+  }
+
+  if (fcntl(fd, F_SETFL, status | flags) == -1) {
+error = Status::FromErrno();
+return error;
+  }
+
+  return error;
+}
+
+NativeProcessAIX::Manager::Manager(MainLoop &mainloop)
+: NativeProcessProtocol::Manager(mainloop) {
+  Status status;
+  m_sigchld_handle = mainloop.RegisterSignal(
+  SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, status);
+  assert(m_sigchld_handle && status.Success());
+}
+
+// Public Static Methods
+
+llvm::Expected>
+NativeProcessAIX::Manager::Launch(ProcessLaunchInfo &launch_info,
+NativeDelegate &native_delegate) {
+  Log *log = GetLog(POSIXLog::Process);
+
+  Status status;
+  ::pid_t pid = ProcessLauncherPosixFork()
+.LaunchProcess(launch_info, status)
+.GetProcessId();
+  LLDB_LOG(log, "pid = {0:x}", pid);
+  if (status.Fail()) {
+LLDB_LOG(log, "failed to launch process: {0}", status);
+return status.ToError();
+  }
+
+  // Wait for the child process to trap on its call to execve.
+  int wstatus = 0;
+  ::pid_t wpid = llvm::sys::RetryAfterSignal(-1, ::waitpid, pid, &wstatus, 0);
+  assert(wpid == pid);
+  UNUSED_IF_ASSERT_DISABLED(wpid);
+  if (!WIFSTOPPED(wstatus)) {
+LLDB_LOG(log, "Could not sync with inferior process: wstatus={1}",
+ WaitStatus::Decode(wstatus));
+return llvm::make_error("Could not sync with inferior 
process",
+ llvm::inconvertibleErrorCode());
+  }
+  LLDB_LOG(log, "inferior started, now in stopped state");
+
+  ProcessInstanceInfo Info;

[Lldb-commits] [lldb] [lldb][AIX] Added base files for NativeProcess Support for AIX (PR #118160)

2024-11-29 Thread Dhruv Srivastava via lldb-commits

https://github.com/DhruvSrivastavaX updated 
https://github.com/llvm/llvm-project/pull/118160

>From 03a290e9c748540b69ca6df7fa9c4481f9cdd3d0 Mon Sep 17 00:00:00 2001
From: Dhruv-Srivastava 
Date: Sat, 30 Nov 2024 01:14:15 -0600
Subject: [PATCH 1/3] Added base files for NativeProcess for AIX

---
 .../source/Plugins/Process/AIX/CMakeLists.txt |  14 +
 .../Plugins/Process/AIX/NativeProcessAIX.cpp  | 288 ++
 .../Plugins/Process/AIX/NativeProcessAIX.h| 134 
 lldb/source/Plugins/Process/CMakeLists.txt|   3 +
 4 files changed, 439 insertions(+)
 create mode 100644 lldb/source/Plugins/Process/AIX/CMakeLists.txt
 create mode 100644 lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp
 create mode 100644 lldb/source/Plugins/Process/AIX/NativeProcessAIX.h

diff --git a/lldb/source/Plugins/Process/AIX/CMakeLists.txt 
b/lldb/source/Plugins/Process/AIX/CMakeLists.txt
new file mode 100644
index 00..4fabbe93022870
--- /dev/null
+++ b/lldb/source/Plugins/Process/AIX/CMakeLists.txt
@@ -0,0 +1,14 @@
+add_lldb_library(lldbPluginProcessAIX
+  NativeProcessAIX.cpp
+
+  LINK_LIBS
+lldbCore
+lldbHost
+lldbSymbol
+lldbTarget
+lldbUtility
+lldbPluginProcessPOSIX
+lldbPluginProcessUtility
+  LINK_COMPONENTS
+Support
+  )
diff --git a/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp 
b/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp
new file mode 100644
index 00..6661693b2fc02b
--- /dev/null
+++ b/lldb/source/Plugins/Process/AIX/NativeProcessAIX.cpp
@@ -0,0 +1,288 @@
+//===-- NativeProcessAIX.cpp ===//
+//
+// 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
+//
+//===--===//
+
+#include "NativeProcessAIX.h"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "NativeThreadAIX.h"
+#include "Plugins/Process/POSIX/ProcessPOSIXLog.h"
+#include "lldb/Core/ModuleSpec.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Host/HostProcess.h"
+#include "lldb/Host/ProcessLaunchInfo.h"
+#include "lldb/Host/PseudoTerminal.h"
+#include "lldb/Host/ThreadLauncher.h"
+#include "lldb/Host/common/NativeRegisterContext.h"
+#include "lldb/Host/aix/Ptrace.h"
+#include "lldb/Host/posix/ProcessLauncherPosixFork.h"
+#include "lldb/Symbol/ObjectFile.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/LLDBAssert.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/RegisterValue.h"
+#include "lldb/Utility/State.h"
+#include "lldb/Utility/Status.h"
+#include "lldb/Utility/StringExtractor.h"
+#include "llvm/ADT/ScopeExit.h"
+#include "llvm/Support/Errno.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Threading.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#ifdef __aarch64__
+#include 
+#include 
+#endif
+
+// Support hardware breakpoints in case it has not been defined
+#ifndef TRAP_HWBKPT
+#define TRAP_HWBKPT 4
+#endif
+
+#ifndef HWCAP2_MTE
+#define HWCAP2_MTE (1 << 18)
+#endif
+
+using namespace lldb;
+using namespace lldb_private;
+using namespace lldb_private::process_aix;
+using namespace llvm;
+
+static constexpr unsigned k_ptrace_word_size = sizeof(void *);
+static_assert(sizeof(long) >= k_ptrace_word_size,
+  "Size of long must be larger than ptrace word size");
+
+// Simple helper function to ensure flags are enabled on the given file
+// descriptor.
+static Status EnsureFDFlags(int fd, int flags) {
+  Status error;
+
+  int status = fcntl(fd, F_GETFL);
+  if (status == -1) {
+error = Status::FromErrno();
+return error;
+  }
+
+  if (fcntl(fd, F_SETFL, status | flags) == -1) {
+error = Status::FromErrno();
+return error;
+  }
+
+  return error;
+}
+
+NativeProcessAIX::Manager::Manager(MainLoop &mainloop)
+: NativeProcessProtocol::Manager(mainloop) {
+  Status status;
+  m_sigchld_handle = mainloop.RegisterSignal(
+  SIGCHLD, [this](MainLoopBase &) { SigchldHandler(); }, status);
+  assert(m_sigchld_handle && status.Success());
+}
+
+// Public Static Methods
+
+llvm::Expected>
+NativeProcessAIX::Manager::Launch(ProcessLaunchInfo &launch_info,
+NativeDelegate &native_delegate) {
+  Log *log = GetLog(POSIXLog::Process);
+
+  Status status;
+  ::pid_t pid = ProcessLauncherPosixFork()
+.LaunchProcess(launch_info, status)
+.GetProcessId();
+  LLDB_LOG(log, "pid = {0:x}", pid);
+  if (status.Fail()) {
+LLDB_LOG(log, "failed to launch process: {0}", status);
+return status.ToError();
+  }
+
+  // Wait for the child process to trap on its call to execve.
+  int wstatus = 0;
+  ::p