[Lldb-commits] [PATCH] D107664: [lldb] [Commands] Remove 'append' from 'platform file open' mode

Michał Górny via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 6 12:47:41 PDT 2021


mgorny created this revision.
mgorny added reviewers: labath, emaste, krytarowski, jasonmolenda, JDevlieghere, clayborg.
mgorny requested review of this revision.

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 not respect
O_APPEND there, 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.


https://reviews.llvm.org/D107664

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


Index: lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
===================================================================
--- lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
+++ lldb/test/API/functionalities/gdb_remote_client/TestGDBRemotePlatformFile.py
@@ -34,7 +34,7 @@
             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",
@@ -69,7 +69,7 @@
                        [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",
Index: lldb/source/Commands/CommandObjectPlatform.cpp
===================================================================
--- lldb/source/Commands/CommandObjectPlatform.cpp
+++ lldb/source/Commands/CommandObjectPlatform.cpp
@@ -498,8 +498,7 @@
                 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107664.364871.patch
Type: text/x-patch
Size: 1872 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210806/1ab575ff/attachment.bin>


More information about the lldb-commits mailing list