[Lldb-commits] [lldb] 2c6d90d - [lldb] [Commands] Remove 'append' from 'platform file open' mode

Michał Górny via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 8 06:42:22 PDT 2021


Author: Michał Górny
Date: 2021-09-08T15:28:03+02:00
New Revision: 2c6d90d7410b77798699ff2fff4182d83db79164

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

LOG: [lldb] [Commands] Remove 'append' from 'platform file open' mode

Remove File::eOpenOptionAppend from the mode used by 'platform file
open' command.  According to POSIX, O_APPEND causes all successive
writes to be done at the end of the file.  This effectively makes
the offset argument to 'platform file write' meaningless.

Furthermore, apparently O_APPEND is not implemented reliably everywhere.
The Linux manpage for pwrite(2) suggests that Linux does respect
O_APPEND there while according to POSIX it should not, so the actual
behavior would be dependent on how the vFile:pwrite packet is
implemented on the server.

Ideally, the mode used for opening flags would be provided via options.
However, changing the default mode seems to be a reasonable intermediate
solution.

Differential Revision: https://reviews.llvm.org/D107664

Added: 
    

Modified: 
    lldb/source/Commands/CommandObjectPlatform.cpp
    lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py

Removed: 
    


################################################################################
diff  --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 8dd0512141645..0274605f2e329 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -498,8 +498,7 @@ class CommandObjectPlatformFOpen : public CommandObjectParsed {
                 lldb::eFilePermissionsWorldRead;
       lldb::user_id_t fd = platform_sp->OpenFile(
           FileSpec(cmd_line),
-          File::eOpenOptionReadWrite | File::eOpenOptionAppend |
-               File::eOpenOptionCanCreate,
+          File::eOpenOptionReadWrite | File::eOpenOptionCanCreate,
           perms, error);
       if (error.Success()) {
         result.AppendMessageWithFormat("File Descriptor = %" PRIu64 "\n", fd);

diff  --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
index 4ba23870e4a0e..b0ecddbdc5579 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
@@ -34,7 +34,7 @@ def vFile(self, packet):
             self.match("platform file close 16",
                        [r"file 16 closed."])
             self.assertPacketLogContains([
-                "vFile:open:2f736f6d652f66696c652e747874,0000020a,000001ed",
+                "vFile:open:2f736f6d652f66696c652e747874,00000202,000001ed",
                 "vFile:pread:10,d,b",
                 "vFile:pwrite:10,b,teststring",
                 "vFile:close:10",
@@ -70,7 +70,7 @@ def vFile(self, packet):
                        [r"error: Invalid argument"],
                        error=True)
             self.assertPacketLogContains([
-                "vFile:open:2f736f6d652f66696c652e747874,0000020a,000001ed",
+                "vFile:open:2f736f6d652f66696c652e747874,00000202,000001ed",
                 "vFile:pread:10,d,b",
                 "vFile:pwrite:10,b,teststring",
                 "vFile:close:10",


        


More information about the lldb-commits mailing list