[Lldb-commits] [lldb] [lldb] Fix redundant condition in Target.cpp (PR #91882)

2024-05-12 Thread via lldb-commits

https://github.com/aabhinavg created 
https://github.com/llvm/llvm-project/pull/91882

This commit addresses issue #87244, where a redundant condition was found in 
the Target.cpp file. Static analyzer cppcheck flagged the issue in the 
Target.cpp file
fix #87244 

>From 9b4160975efe059f39a842689b1f750a10453203 Mon Sep 17 00:00:00 2001
From: aabhinavg 
Date: Sun, 12 May 2024 12:42:59 +0530
Subject: [PATCH] Fix redundant condition in Target.cpp

This commit addresses issue #87244, where a redundant condition was found in 
the Target.cpp file.
Static analyzer cppcheck flagged the issue in the Target.cpp file
---
 lldb/source/Target/Target.cpp | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 82f3040e539a3..fe87728a33dc8 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -841,12 +841,14 @@ static bool CheckIfWatchpointsSupported(Target *target, 
Status &error) {
   if (!num_supported_hardware_watchpoints)
 return true;
 
-  if (num_supported_hardware_watchpoints == 0) {
-error.SetErrorStringWithFormat(
-"Target supports (%u) hardware watchpoint slots.\n",
-*num_supported_hardware_watchpoints);
-return false;
-  }
+  // If num_supported_hardware_watchpoints is zero, set an 
+  //error message and return false.
+
+  error.SetErrorStringWithFormat(
+  "Target supports (%u) hardware watchpoint slots.\n",
+  *num_supported_hardware_watchpoints);
+  return false;
+  
   return true;
 }
 

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


[Lldb-commits] [lldb] [lldb] Fix redundant condition in Target.cpp (PR #91882)

2024-05-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (aabhinavg)


Changes

This commit addresses issue #87244, where a redundant condition was 
found in the Target.cpp file. Static analyzer cppcheck flagged the issue in the 
Target.cpp file
fix #87244 

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


1 Files Affected:

- (modified) lldb/source/Target/Target.cpp (+8-6) 


``diff
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 82f3040e539a3..fe87728a33dc8 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -841,12 +841,14 @@ static bool CheckIfWatchpointsSupported(Target *target, 
Status &error) {
   if (!num_supported_hardware_watchpoints)
 return true;
 
-  if (num_supported_hardware_watchpoints == 0) {
-error.SetErrorStringWithFormat(
-"Target supports (%u) hardware watchpoint slots.\n",
-*num_supported_hardware_watchpoints);
-return false;
-  }
+  // If num_supported_hardware_watchpoints is zero, set an 
+  //error message and return false.
+
+  error.SetErrorStringWithFormat(
+  "Target supports (%u) hardware watchpoint slots.\n",
+  *num_supported_hardware_watchpoints);
+  return false;
+  
   return true;
 }
 

``




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


[Lldb-commits] [lldb] [lldb] Fix redundant condition in Target.cpp (PR #91882)

2024-05-12 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 63224d717108d927e998da8a67050a6cc5dd74a2 
9b4160975efe059f39a842689b1f750a10453203 -- lldb/source/Target/Target.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index fe87728a33..afc9506d3d 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -841,14 +841,14 @@ static bool CheckIfWatchpointsSupported(Target *target, 
Status &error) {
   if (!num_supported_hardware_watchpoints)
 return true;
 
-  // If num_supported_hardware_watchpoints is zero, set an 
-  //error message and return false.
+  // If num_supported_hardware_watchpoints is zero, set an
+  // error message and return false.
 
   error.SetErrorStringWithFormat(
   "Target supports (%u) hardware watchpoint slots.\n",
   *num_supported_hardware_watchpoints);
   return false;
-  
+
   return true;
 }
 

``




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


[Lldb-commits] [lldb] [llvm] [lldb] Refactor string manipulation in Debugger.cpp (#91209) (PR #91880)

2024-05-12 Thread Youngsuk Kim via lldb-commits

JOE1994 wrote:

A new user already asked to be assigned to work on #91209 2 days ago in the 
comments.
**I think that user deserves an opportunity to work on the issue**.

Next time when you see a **"good first issue"** which a new user had already 
asked to get assigned to,
please assign it to the new user.

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


[Lldb-commits] [lldb] [llvm] [lldb] Refactor string manipulation in Debugger.cpp (#91209) (PR #91880)

2024-05-12 Thread Youngsuk Kim via lldb-commits

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


[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [openmp] [polly] fix(python): fix comparison to None (PR #91857)

2024-05-12 Thread Oleksandr Alex Zinenko via lldb-commits

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

LGTM for the MLIR part. Please seek approval from relevant reviewers for all 
other subprojects.

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


[Lldb-commits] [lldb] [lldb] Fixed the test TestQuoting (PR #91886)

2024-05-12 Thread Dmitry Vasilyev via lldb-commits

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

os.path.join() uses the path separator of the host OS by default. outfile_arg 
will be incorrect in case of Windows host and Linux target. Use 
lldbutil.append_to_process_working_directory() instead.

>From f6135c1b825afd9fe733b845dfd12ffe3c162840 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sun, 12 May 2024 18:08:50 +0400
Subject: [PATCH] [lldb] Fixed the test TestQuoting

os.path.join() uses the path separator of the host OS by default. outfile_arg 
will be incorrect in case of Windows host and Linux target. Use 
lldbutil.append_to_process_working_directory() instead.
---
 lldb/test/API/commands/settings/quoting/TestQuoting.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/test/API/commands/settings/quoting/TestQuoting.py 
b/lldb/test/API/commands/settings/quoting/TestQuoting.py
index 393f4be3c8242..d6246a5309c5d 100644
--- a/lldb/test/API/commands/settings/quoting/TestQuoting.py
+++ b/lldb/test/API/commands/settings/quoting/TestQuoting.py
@@ -51,8 +51,8 @@ def expect_args(self, args_in, args_out):
 outfile = self.getBuildArtifact(filename)
 
 if lldb.remote_platform:
-outfile_arg = os.path.join(
-lldb.remote_platform.GetWorkingDirectory(), filename
+outfile_arg = lldbutil.append_to_process_working_directory(
+self, filename
 )
 else:
 outfile_arg = outfile

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


[Lldb-commits] [lldb] [lldb] Fixed the test TestQuoting (PR #91886)

2024-05-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

os.path.join() uses the path separator of the host OS by default. outfile_arg 
will be incorrect in case of Windows host and Linux target. Use 
lldbutil.append_to_process_working_directory() instead.

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


1 Files Affected:

- (modified) lldb/test/API/commands/settings/quoting/TestQuoting.py (+2-2) 


``diff
diff --git a/lldb/test/API/commands/settings/quoting/TestQuoting.py 
b/lldb/test/API/commands/settings/quoting/TestQuoting.py
index 393f4be3c8242..d6246a5309c5d 100644
--- a/lldb/test/API/commands/settings/quoting/TestQuoting.py
+++ b/lldb/test/API/commands/settings/quoting/TestQuoting.py
@@ -51,8 +51,8 @@ def expect_args(self, args_in, args_out):
 outfile = self.getBuildArtifact(filename)
 
 if lldb.remote_platform:
-outfile_arg = os.path.join(
-lldb.remote_platform.GetWorkingDirectory(), filename
+outfile_arg = lldbutil.append_to_process_working_directory(
+self, filename
 )
 else:
 outfile_arg = outfile

``




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


[Lldb-commits] [lldb] [lldb] Fixed the test TestQuoting (PR #91886)

2024-05-12 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 
1d6bf0ca29322b08e8b50681d440e7182441b025...f6135c1b825afd9fe733b845dfd12ffe3c162840
 lldb/test/API/commands/settings/quoting/TestQuoting.py
``





View the diff from darker here.


``diff
--- TestQuoting.py  2024-05-12 14:08:50.00 +
+++ TestQuoting.py  2024-05-12 14:13:04.914847 +
@@ -49,13 +49,11 @@
 
 filename = SettingsCommandTestCase.output_file_name
 outfile = self.getBuildArtifact(filename)
 
 if lldb.remote_platform:
-outfile_arg = lldbutil.append_to_process_working_directory(
-self, filename
-)
+outfile_arg = lldbutil.append_to_process_working_directory(self, 
filename)
 else:
 outfile_arg = outfile
 
 self.runCmd("process launch -- %s %s" % (outfile_arg, args_in))
 

``




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


[Lldb-commits] [lldb] [lldb][Windows] Enforce exec permission using Platform::Install() from Windows host (PR #91887)

2024-05-12 Thread Dmitry Vasilyev via lldb-commits

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

Target::Install() set 0700 permissions for the main executable file. 
Platform::Install() just copies permissions from the source. But the permission 
eFilePermissionsUserExecute is missing on the Windows host. A lot of tests 
failed in case of Windows host and Linux target because of this issue. There is 
no API to provide the exec flag. This patch set the permission 
eFilePermissionsUserExecute for all files installed via Platform::Install() 
from the Windows host. It fixes a lot of tests in case of Windows host and 
Linux target.

>From 94f75bd21aac412b9971ccc8dc8382e4a75dc1cd Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sun, 12 May 2024 18:29:09 +0400
Subject: [PATCH] [lldb][Windows] Enforce exec permission using
 Platform::Install() from Windows host

Target::Install() set 0700 permissions for the main executable file. 
Platform::Install() just copies permissions from the source. But the permission 
eFilePermissionsUserExecute is missing on the Windows host. A lot of tests 
failed in case of Windows host and Linux target because of this issue. There is 
no API to provide the exec flag. This patch set the permission 
eFilePermissionsUserExecute for all files installed via Platform::Install() 
from the Windows host. It fixes a lot of tests in case of Windows host and 
Linux target.
---
 lldb/source/Target/Platform.cpp | 4 
 1 file changed, 4 insertions(+)

diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 4af4aa68ccd01..0e7739b3712d7 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -1227,6 +1227,10 @@ Status Platform::PutFile(const FileSpec &source, const 
FileSpec &destination,
   if (permissions == 0)
 permissions = lldb::eFilePermissionsFileDefault;
 
+#if defined(_WIN32)
+  permissions |= lldb::eFilePermissionsUserExecute;
+#endif
+
   lldb::user_id_t dest_file = OpenFile(
   destination, File::eOpenOptionCanCreate | File::eOpenOptionWriteOnly |
File::eOpenOptionTruncate | 
File::eOpenOptionCloseOnExec,

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


[Lldb-commits] [lldb] [lldb][Windows] Enforce exec permission using Platform::Install() from Windows host (PR #91887)

2024-05-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

Target::Install() set 0700 permissions for the main executable file. 
Platform::Install() just copies permissions from the source. But the permission 
eFilePermissionsUserExecute is missing on the Windows host. A lot of tests 
failed in case of Windows host and Linux target because of this issue. There is 
no API to provide the exec flag. This patch set the permission 
eFilePermissionsUserExecute for all files installed via Platform::Install() 
from the Windows host. It fixes a lot of tests in case of Windows host and 
Linux target.

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


1 Files Affected:

- (modified) lldb/source/Target/Platform.cpp (+4) 


``diff
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 4af4aa68ccd01..0e7739b3712d7 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -1227,6 +1227,10 @@ Status Platform::PutFile(const FileSpec &source, const 
FileSpec &destination,
   if (permissions == 0)
 permissions = lldb::eFilePermissionsFileDefault;
 
+#if defined(_WIN32)
+  permissions |= lldb::eFilePermissionsUserExecute;
+#endif
+
   lldb::user_id_t dest_file = OpenFile(
   destination, File::eOpenOptionCanCreate | File::eOpenOptionWriteOnly |
File::eOpenOptionTruncate | 
File::eOpenOptionCloseOnExec,

``




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


[Lldb-commits] [lldb] [lldb] Fixed the test TestQuoting (PR #91886)

2024-05-12 Thread Dmitry Vasilyev via lldb-commits

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

>From f6135c1b825afd9fe733b845dfd12ffe3c162840 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sun, 12 May 2024 18:08:50 +0400
Subject: [PATCH 1/2] [lldb] Fixed the test TestQuoting

os.path.join() uses the path separator of the host OS by default. outfile_arg 
will be incorrect in case of Windows host and Linux target. Use 
lldbutil.append_to_process_working_directory() instead.
---
 lldb/test/API/commands/settings/quoting/TestQuoting.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/test/API/commands/settings/quoting/TestQuoting.py 
b/lldb/test/API/commands/settings/quoting/TestQuoting.py
index 393f4be3c8242..d6246a5309c5d 100644
--- a/lldb/test/API/commands/settings/quoting/TestQuoting.py
+++ b/lldb/test/API/commands/settings/quoting/TestQuoting.py
@@ -51,8 +51,8 @@ def expect_args(self, args_in, args_out):
 outfile = self.getBuildArtifact(filename)
 
 if lldb.remote_platform:
-outfile_arg = os.path.join(
-lldb.remote_platform.GetWorkingDirectory(), filename
+outfile_arg = lldbutil.append_to_process_working_directory(
+self, filename
 )
 else:
 outfile_arg = outfile

>From ff85c4d9cb0c749fe75be1493dd22b7f7c0de9be Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sun, 12 May 2024 18:35:12 +0400
Subject: [PATCH 2/2] Updated the formatting by darker

---
 lldb/test/API/commands/settings/quoting/TestQuoting.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lldb/test/API/commands/settings/quoting/TestQuoting.py 
b/lldb/test/API/commands/settings/quoting/TestQuoting.py
index d6246a5309c5d..60ad4e0a4 100644
--- a/lldb/test/API/commands/settings/quoting/TestQuoting.py
+++ b/lldb/test/API/commands/settings/quoting/TestQuoting.py
@@ -51,9 +51,7 @@ def expect_args(self, args_in, args_out):
 outfile = self.getBuildArtifact(filename)
 
 if lldb.remote_platform:
-outfile_arg = lldbutil.append_to_process_working_directory(
-self, filename
-)
+outfile_arg = lldbutil.append_to_process_working_directory(self, 
filename)
 else:
 outfile_arg = outfile
 

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


[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [openmp] [polly] fix(python): fix comparison to None (PR #91857)

2024-05-12 Thread Mircea Trofin via lldb-commits

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

LGTM for the `ctx_profile` part.

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


[Lldb-commits] [lldb] [lldb] Fixed the test TestSettings (PR #91915)

2024-05-12 Thread Dmitry Vasilyev via lldb-commits

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

The setting `platform.module-cache-directory` is a local path on the host. It 
cannot be set to a working directory from the remote target. This test failed 
in case of Windows host and Linux target. Use the local build dir instead.

>From d16f016a3e5880b151d769ff7a8095c487a409d7 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Mon, 13 May 2024 09:48:19 +0400
Subject: [PATCH] [lldb] Fixed the test TestSettings

The setting `platform.module-cache-directory` is a local path on the host. It 
cannot be set to a working directory from the remote target. This test failed 
in case of Windows host and Linux target. Use the local build dir instead.
---
 lldb/test/API/commands/settings/TestSettings.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/test/API/commands/settings/TestSettings.py 
b/lldb/test/API/commands/settings/TestSettings.py
index 104a9f09788c3..385acceb7a8b5 100644
--- a/lldb/test/API/commands/settings/TestSettings.py
+++ b/lldb/test/API/commands/settings/TestSettings.py
@@ -953,7 +953,7 @@ def test_settings_api(self):
 
 # Test OptionValueFileSpec
 self.verify_setting_value_json(
-"platform.module-cache-directory", 
self.get_process_working_directory()
+"platform.module-cache-directory", self.getBuildDir()
 )
 
 # Test OptionValueArray

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


[Lldb-commits] [lldb] [lldb] Fixed the test TestSettings (PR #91915)

2024-05-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

The setting `platform.module-cache-directory` is a local path on the host. It 
cannot be set to a working directory from the remote target. This test failed 
in case of Windows host and Linux target. Use the local build dir instead.

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


1 Files Affected:

- (modified) lldb/test/API/commands/settings/TestSettings.py (+1-1) 


``diff
diff --git a/lldb/test/API/commands/settings/TestSettings.py 
b/lldb/test/API/commands/settings/TestSettings.py
index 104a9f09788c3..385acceb7a8b5 100644
--- a/lldb/test/API/commands/settings/TestSettings.py
+++ b/lldb/test/API/commands/settings/TestSettings.py
@@ -953,7 +953,7 @@ def test_settings_api(self):
 
 # Test OptionValueFileSpec
 self.verify_setting_value_json(
-"platform.module-cache-directory", 
self.get_process_working_directory()
+"platform.module-cache-directory", self.getBuildDir()
 )
 
 # Test OptionValueArray

``




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


[Lldb-commits] [lldb] [lldb] Fixed the test TestSettings (PR #91915)

2024-05-12 Thread Dmitry Vasilyev via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix the test TestGdbRemotePlatformFile (PR #91918)

2024-05-12 Thread Dmitry Vasilyev via lldb-commits

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

It is necessary to transfer the test file to/from the really remote target (for 
example Windows host and Linux target). Also ignore chmod check in case of the 
Windows host.

>From 24d0eb93672570aec4e53dfcf10b53eac8c6acb9 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Mon, 13 May 2024 10:34:04 +0400
Subject: [PATCH] [lldb] Fix the test TestGdbRemotePlatformFile

It is necessary to transfer the test file to/from the really remote target (for 
example Windows host and Linux target).
Also ignore chmod check in case of Windows host.
---
 .../lldb-server/TestGdbRemotePlatformFile.py  | 47 +--
 1 file changed, 44 insertions(+), 3 deletions(-)

diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
index 4c8ce01e8ba31..13274696a9a5c 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
@@ -1,6 +1,7 @@
 # lldb test suite imports
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import TestBase
+from lldbsuite.test import lldbutil
 
 # gdb-remote-specific imports
 import lldbgdbserverutils
@@ -108,6 +109,20 @@ def test_platform_file_wronly_fail(self):
 )
 self.expect_gdbremote_sequence()
 
+def remote_install(self, path, filename="test"):
+if lldb.remote_platform:
+remote_path = lldbutil.append_to_process_working_directory(self, 
filename)
+err = lldb.remote_platform.Install(
+lldb.SBFileSpec(path, True), lldb.SBFileSpec(remote_path, 
False)
+)
+if err.Fail():
+raise Exception(
+"remote_platform.Install('%s', '%s') failed: %s"
+% (path, remote_path, err)
+)
+path = remote_path
+return path
+
 @skipIfWindows
 @add_test_categories(["llgs"])
 def test_platform_file_wronly_creat_excl_fail(self):
@@ -117,6 +132,7 @@ def test_platform_file_wronly_creat_excl_fail(self):
 temp_file = self.getBuildArtifact("test")
 with open(temp_file, "wb"):
 pass
+temp_file = self.remote_install(temp_file)
 
 # attempt to open the file with O_CREAT|O_EXCL
 self.do_handshake()
@@ -140,6 +156,7 @@ def test_platform_file_size(self):
 test_data = b"test data of some length"
 with open(temp_path, "wb") as temp_file:
 temp_file.write(test_data)
+temp_path = self.remote_install(temp_path)
 
 self.do_handshake()
 self.test_sequence.add_log_lines(
@@ -167,7 +184,11 @@ def test_platform_file_mode(self):
 test_mode = 0o751
 
 with open(temp_path, "wb") as temp_file:
-os.chmod(temp_file.fileno(), test_mode)
+if lldbplatformutil.getHostPlatform() == "windows":
+test_mode = 0o700
+else:
+os.chmod(temp_file.fileno(), test_mode)
+temp_path = self.remote_install(temp_path)
 
 self.do_handshake()
 self.test_sequence.add_log_lines(
@@ -213,6 +234,7 @@ def test_platform_file_exists(self):
 temp_path = self.getBuildArtifact("test")
 with open(temp_path, "wb"):
 pass
+temp_path = self.remote_install(temp_path)
 
 self.do_handshake()
 self.test_sequence.add_log_lines(
@@ -244,6 +266,10 @@ def test_platform_file_exists_not(self):
 self.expect_gdbremote_sequence()
 
 @skipIfWindows
+# FIXME: lldb.remote_platform.Install() cannot copy opened temp file on 
Windows.
+# It is possible to use tempfile.NamedTemporaryFile(..., delete=False) and
+# delete the temp file manually at the end.
+@skipIf(hostoslist=["windows"])
 @add_test_categories(["llgs"])
 def test_platform_file_fstat(self):
 server = self.connect_to_debug_monitor()
@@ -252,12 +278,13 @@ def test_platform_file_fstat(self):
 with tempfile.NamedTemporaryFile() as temp_file:
 temp_file.write(b"some test data for stat")
 temp_file.flush()
+temp_path = self.remote_install(temp_file.name, "temp")
 
 self.do_handshake()
 self.test_sequence.add_log_lines(
 [
 "read packet: $vFile:open:%s,0,0#00"
-% (binascii.b2a_hex(temp_file.name.encode()).decode(),),
+% (binascii.b2a_hex(temp_path.encode()).decode(),),
 {
 "direction": "send",
 "regex": r"^\$F([0-9a-fA-F]+)#[0-9a-fA-F]{2}$",
@@ -359,9 +386,12 @@ def vFile_test(
 
 if creat:
 self.assertFalse(os.path.exists(temp_path))
+if lldb.remote_platform:
+temp_path = lldbutil.append_to_process_working_directory(self, 
"test")
 

[Lldb-commits] [lldb] [lldb] Fix the test TestGdbRemotePlatformFile (PR #91918)

2024-05-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

It is necessary to transfer the test file to/from the really remote target (for 
example Windows host and Linux target). Also ignore chmod check in case of the 
Windows host.

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


1 Files Affected:

- (modified) lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py 
(+44-3) 


``diff
diff --git a/lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py 
b/lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
index 4c8ce01e8ba31..13274696a9a5c 100644
--- a/lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
+++ b/lldb/test/API/tools/lldb-server/TestGdbRemotePlatformFile.py
@@ -1,6 +1,7 @@
 # lldb test suite imports
 from lldbsuite.test.decorators import *
 from lldbsuite.test.lldbtest import TestBase
+from lldbsuite.test import lldbutil
 
 # gdb-remote-specific imports
 import lldbgdbserverutils
@@ -108,6 +109,20 @@ def test_platform_file_wronly_fail(self):
 )
 self.expect_gdbremote_sequence()
 
+def remote_install(self, path, filename="test"):
+if lldb.remote_platform:
+remote_path = lldbutil.append_to_process_working_directory(self, 
filename)
+err = lldb.remote_platform.Install(
+lldb.SBFileSpec(path, True), lldb.SBFileSpec(remote_path, 
False)
+)
+if err.Fail():
+raise Exception(
+"remote_platform.Install('%s', '%s') failed: %s"
+% (path, remote_path, err)
+)
+path = remote_path
+return path
+
 @skipIfWindows
 @add_test_categories(["llgs"])
 def test_platform_file_wronly_creat_excl_fail(self):
@@ -117,6 +132,7 @@ def test_platform_file_wronly_creat_excl_fail(self):
 temp_file = self.getBuildArtifact("test")
 with open(temp_file, "wb"):
 pass
+temp_file = self.remote_install(temp_file)
 
 # attempt to open the file with O_CREAT|O_EXCL
 self.do_handshake()
@@ -140,6 +156,7 @@ def test_platform_file_size(self):
 test_data = b"test data of some length"
 with open(temp_path, "wb") as temp_file:
 temp_file.write(test_data)
+temp_path = self.remote_install(temp_path)
 
 self.do_handshake()
 self.test_sequence.add_log_lines(
@@ -167,7 +184,11 @@ def test_platform_file_mode(self):
 test_mode = 0o751
 
 with open(temp_path, "wb") as temp_file:
-os.chmod(temp_file.fileno(), test_mode)
+if lldbplatformutil.getHostPlatform() == "windows":
+test_mode = 0o700
+else:
+os.chmod(temp_file.fileno(), test_mode)
+temp_path = self.remote_install(temp_path)
 
 self.do_handshake()
 self.test_sequence.add_log_lines(
@@ -213,6 +234,7 @@ def test_platform_file_exists(self):
 temp_path = self.getBuildArtifact("test")
 with open(temp_path, "wb"):
 pass
+temp_path = self.remote_install(temp_path)
 
 self.do_handshake()
 self.test_sequence.add_log_lines(
@@ -244,6 +266,10 @@ def test_platform_file_exists_not(self):
 self.expect_gdbremote_sequence()
 
 @skipIfWindows
+# FIXME: lldb.remote_platform.Install() cannot copy opened temp file on 
Windows.
+# It is possible to use tempfile.NamedTemporaryFile(..., delete=False) and
+# delete the temp file manually at the end.
+@skipIf(hostoslist=["windows"])
 @add_test_categories(["llgs"])
 def test_platform_file_fstat(self):
 server = self.connect_to_debug_monitor()
@@ -252,12 +278,13 @@ def test_platform_file_fstat(self):
 with tempfile.NamedTemporaryFile() as temp_file:
 temp_file.write(b"some test data for stat")
 temp_file.flush()
+temp_path = self.remote_install(temp_file.name, "temp")
 
 self.do_handshake()
 self.test_sequence.add_log_lines(
 [
 "read packet: $vFile:open:%s,0,0#00"
-% (binascii.b2a_hex(temp_file.name.encode()).decode(),),
+% (binascii.b2a_hex(temp_path.encode()).decode(),),
 {
 "direction": "send",
 "regex": r"^\$F([0-9a-fA-F]+)#[0-9a-fA-F]{2}$",
@@ -359,9 +386,12 @@ def vFile_test(
 
 if creat:
 self.assertFalse(os.path.exists(temp_path))
+if lldb.remote_platform:
+temp_path = lldbutil.append_to_process_working_directory(self, 
"test")
 else:
 with open(temp_path, "wb") as temp_file:
 temp_file.write(test_data.encode())
+temp_path = self.remote_install(temp_path)
 
 # open the file for reading
 self.do_handshake()
@@ -448,8 +478,19 @@ def vFile_test(
 
 if wr