[lldb] [gdb-remote] Add eOpenOptionReadWrite for future gdb compat

Modify OpenOptions enum to open the future path into synchronizing
vFile:open bits with GDB.  Currently, LLDB and GDB use different flag
models effectively making it impossible to match bits.  Notably, LLDB
uses two bits to indicate read and write status, and uses union of both
for read/write.  GDB uses a value of 0 for read-only, 1 for write-only
and 2 for read/write.

In order to future-proof the code for the GDB variant:

1. Add a distinct eOpenOptionReadWrite constant to be used instead
   of (eOpenOptionRead | eOpenOptionWrite) when R/W access is required.

2. Rename eOpenOptionRead and eOpenOptionWrite to eOpenOptionReadOnly
   and eOpenOptionWriteOnly respectively, to make it clear that they
   do not mean to be combined and require update to all call sites.

3. Use the intersection of all three flags when matching against
   the three possible values.

This commit does not change the actual bits used by LLDB.

Differential Revision: https://reviews.llvm.org/D106984
This commit is contained in:
Michał Górny
2021-07-28 20:07:03 +02:00
parent 8a7c657c4d
commit 14735cab65
31 changed files with 110 additions and 82 deletions

View File

@@ -2660,7 +2660,7 @@ bool RenderScriptRuntime::SaveAllocation(Stream &strm, const uint32_t alloc_id,
FileSpec file_spec(path);
FileSystem::Instance().Resolve(file_spec);
auto file = FileSystem::Instance().Open(
file_spec, File::eOpenOptionWrite | File::eOpenOptionCanCreate |
file_spec, File::eOpenOptionWriteOnly | File::eOpenOptionCanCreate |
File::eOpenOptionTruncate);
if (!file) {
@@ -4585,8 +4585,9 @@ public:
if (outfile_spec) {
// Open output file
std::string path = outfile_spec.GetPath();
auto file = FileSystem::Instance().Open(
outfile_spec, File::eOpenOptionWrite | File::eOpenOptionCanCreate);
auto file = FileSystem::Instance().Open(outfile_spec,
File::eOpenOptionWriteOnly |
File::eOpenOptionCanCreate);
if (file) {
output_stream_storage =
std::make_unique<StreamFile>(std::move(file.get()));