Re: [Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-28 Thread Pavel Labath via lldb-commits
It looks like that in this case (and possibly many others) a wrapper class is not necessary. If we just want to log the inputs and outputs of mmap(), we just need to wrap the factory function (as we have done here) and let the users access the llvm class directly. On 27 February 2017 at 20:05,

Re: [Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-27 Thread Jim Ingham via lldb-commits
Having library functions that don't return good errors seems like such an obvious failing that it shouldn't be hard to motivate fixing that. Then our logging can go in the wrapper classes, using those errors. That seems like a pattern that solves the "don't duplicate code" problem and the

Re: [Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-27 Thread Zachary Turner via lldb-commits
Oh that wasn't in response to the comment about wrapper classes, that was just a general comment about the fact that we lose logging by moving to LLVM's implementation at all. If we have our own implementation, we could in theory log at various stages of the mmaping process, but by moving to a

Re: [Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-27 Thread Jim Ingham via lldb-commits
I worry about stripping out the wrappers, because there are some differences in how lldb operates from llvm that I don't think we want to push down into llvm - in this case I'm thinking particularly about logging. DataBufferMemoryMap did a bunch of logging, which presumably would get lost if

Re: [Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-27 Thread Zachary Turner via lldb-commits
I didn't refer to mmaping in the name because LLVM's MemoryBuffer is not necessarily mmap'ed. It might be mmap'ed and it might not be. Depends on various factors such as whether you specify the IsVolatile flag, how big the file is, and maybe a few other things. After this change we have

Re: [Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-27 Thread Jim Ingham via lldb-commits
This is kind of after the fact, but why didn't we reuse DataBufferMemoryMap for the Memory Map data buffer that now happens to be backed by an LLVM implementation? DataBufferLLVM doesn't really tell anybody what the thing does w/o looking up the implementation. Jim > On Feb 27, 2017, at

Re: [Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-27 Thread Pavel Labath via lldb-commits
I was thinking of a simple test like "call get on an existing file and make sure it returns something reasonable" and "call get on a non-existing file and make sure it returns null". This is a very thin wrapper over over the llvm code, so I don't insist on it though... On 24 February 2017 at

[Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-24 Thread Zachary Turner via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL296159: Delete DataBufferMemoryMap. (authored by zturner). Changed prior to commit: https://reviews.llvm.org/D30054?vs=89547=89701#toc Repository: rL LLVM https://reviews.llvm.org/D30054 Files:

[Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-24 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment. I am not sure if this is a voting situation, but I agree with what Zachary said above. Since we're already speaking about tests, it looks like the new DataBufferLLVM class could use a unit test or two, just so we get in the habit of writing those.

[Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-23 Thread Zachary Turner via Phabricator via lldb-commits
zturner added a comment. The main concern I have with adding null checks is that I think it actually *increases* your risk of crashing. All of a sudden you've introduced an entirely new branch / code-path that is completely untested. Worse, it only occurs in a situation where you've

[Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-23 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment. I would still vote to check Buffer for NULL. GetByteSize() and GetBytes() are usually accessed one time so there won't be a performance issue. If anyone wanted to actually use a DataBufferLLVM as a member variable, they would need to use a std::unique_ptr to one with

[Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-23 Thread Zachary Turner via Phabricator via lldb-commits
zturner updated this revision to Diff 89547. zturner added a comment. Updated with suggestions from clayborg@. It seems wasteful to me check the pointer on every single call to read when we can check it once on creation. So I've added an assert in the constructor and documented with doxygen

[Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-23 Thread Zachary Turner via Phabricator via lldb-commits
zturner updated this revision to Diff 89542. https://reviews.llvm.org/D30054 Files: lldb/include/lldb/Core/DataBufferHeap.h lldb/include/lldb/Core/DataBufferLLVM.h lldb/include/lldb/Core/DataBufferMemoryMap.h lldb/include/lldb/Host/FileSpec.h lldb/source/Core/CMakeLists.txt

[Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-23 Thread Zachary Turner via Phabricator via lldb-commits
zturner added inline comments. Comment at: lldb/include/lldb/Core/DataBufferLLVM.h:43 + uint8_t *GetBytes() override { +llvm_unreachable("Not implemented!"); +return nullptr; labath wrote: > This makes pretty much everything fail. Most of the code base

[Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-23 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment. I've tried this out on linux. I got it working only after making the following modifications: Comment at: lldb/include/lldb/Core/DataBufferLLVM.h:15 +#include "lldb/Host/FileSpec.h" +#include "llvm/Support/MemoryBuffer.h" + add

[Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-22 Thread Zachary Turner via Phabricator via lldb-commits
zturner updated this revision to Diff 89453. zturner added a comment. Updated with suggestions from labath@ https://reviews.llvm.org/D30054 Files: lldb/include/lldb/Core/DataBufferHeap.h lldb/include/lldb/Core/DataBufferLLVM.h lldb/include/lldb/Core/DataBufferMemoryMap.h

[Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-22 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment. I think you are still waiting to get the llvm changes sorted out, but this side of it looks fine to me (modulo a couple of nits). Comment at: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp:414 + +data_sp =

[Lldb-commits] [PATCH] D30054: Delete DataBufferMemoryMap

2017-02-16 Thread Zachary Turner via Phabricator via lldb-commits
zturner created this revision. Herald added a subscriber: mgorny. This depends on https://reviews.llvm.org/D30010 going in first, but assuming that's successful, this patch updates LLDB to use LLVM's memory mapping instead of `DataBufferMemoryMap`. Since this also makes `DataBufferMemoryMap`