[Lldb-commits] [PATCH] D40079: Make sure DataBufferLLVM contents are writable

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 15 09:50:58 PST 2017


On 15 November 2017 at 17:42, Zachary Turner <zturner at google.com> wrote:
> Can we just extend llvm's mapped_file_region to support a boolean Writable
> flag?
>
mapped_file_region already can be writable. The feature it is missing
is the ability to *not* use mmap. And that's not a good idea, as the
whole purpose of that class is to mmap things.

We could theoretically add a writable flag to llvm::MemoryBuffer,
but's its header says:
/// This interface provides simple ***read-only*** access to a block
of memory, and ...

I am not sure we should be changing that as MemoryBuffers are used all
over the place.

That said, I have found at least two instances in clang where they are
const_casting a MemoryBuffer and writing to it (just like we were),
but this behavior seems to be an exception, and at least one of those
two instances is a huge hack.

In the long run, we probably should have some MemoryBuffer-like class
that is writable, but this I think this need to be considered very
carefully. I am willing do to the work there, but I'd like to fix this
somehow first, as this is a huge regression.


More information about the lldb-commits mailing list