<div dir="ltr">There may be some cases where we're no longer mmaping where we used to, but looking at LLVM's implementation, that would only happen if the file is fairly small, and there's a comment in LLVM explaining why they don't mmap small files. So I think that's actually an improvement for LLDB (although I doubt we are frequently mapping very small files, so it might be a non issue).<div><br></div><div>You are correct that we lose some logging this way, but in exchange we get better tested code. The code in question that we lose though is basically just the call to mmap and the setup to prepare that call. As long as we have the return code from mmap, we should be able to log the error just as gracefully. Granted, the LLVM code doesn't return an error code right now, but it seems like a worthy improvement.</div><div><br></div><div>I'm not sure where the right balance is between facilitating post-mortem diagnostics and reducing the amount of problems that happen in the first place, but I feel kind of dirty duplicating code just so that we can add logging. Maybe there's a case to be made for adding logging hooks into LLVM.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Feb 27, 2017 at 11:00 AM Jim Ingham <<a href="mailto:jingham@apple.com">jingham@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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 you just went directly to the llvm classes. Most of the tools that build out of the llvm toolset are one-pass tools, and reproducing problems with their operation is generally not terribly hard. So having a rich logging feature is not all that necessary, and the burden of adding it to the code not worth the benefit. But lldb is much more state dependent, and is exposed to a wider variety of the vagaries of system behavior, and being both an interactive tool and the API's for GUI debuggers, has a wider and more unpredictable array of of use cases. Having good logging has saved my day many and many's the time over the years, and I don't want to lose that.<br class="gmail_msg">
<br class="gmail_msg">
So while I don't have any objection to changing the backing implementation, I still see value in the wrapper classes.<br class="gmail_msg">
<br class="gmail_msg">
You say LLVM memory buffers can be heap or mmap, but presumably when used by what used to be DataBufferMemoryMap they are using the memory map version, right? Still seems useful to have the class name say what the thing is.<br class="gmail_msg">
<br class="gmail_msg">
Jim<br class="gmail_msg">
<br class="gmail_msg">
> On Feb 27, 2017, at 10:40 AM, Zachary Turner <<a href="mailto:zturner@google.com" class="gmail_msg" target="_blank">zturner@google.com</a>> wrote:<br class="gmail_msg">
><br class="gmail_msg">
> 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.<br class="gmail_msg">
><br class="gmail_msg">
> After this change we have DataBufferLLVM and DataBufferHeap. But it turns out an LLVM MemoryBuffer can also be backed by the heap, which now makes DataBufferHeap redundant as well. So I think longer term we might be able to get rid of all of LLDB's DataBuffer stuff entirely, and everything will just use llvm::MemoryBuffer directly.<br class="gmail_msg">
><br class="gmail_msg">
> What do you think?<br class="gmail_msg">
><br class="gmail_msg">
> On Mon, Feb 27, 2017 at 10:36 AM Jim Ingham <<a href="mailto:jingham@apple.com" class="gmail_msg" target="_blank">jingham@apple.com</a>> wrote:<br class="gmail_msg">
> 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.<br class="gmail_msg">
><br class="gmail_msg">
> Jim<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> > On Feb 27, 2017, at 2:56 AM, Pavel Labath via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org" class="gmail_msg" target="_blank">lldb-commits@lists.llvm.org</a>> wrote:<br class="gmail_msg">
> ><br class="gmail_msg">
> > I was thinking of a simple test like "call get on an existing file and<br class="gmail_msg">
> > make sure it returns something reasonable" and "call get on a<br class="gmail_msg">
> > non-existing file and make sure it returns null". This is a very thin<br class="gmail_msg">
> > wrapper over over the llvm code, so I don't insist on it though...<br class="gmail_msg">
> ><br class="gmail_msg">
> > On 24 February 2017 at 15:18, Zachary Turner <<a href="mailto:zturner@google.com" class="gmail_msg" target="_blank">zturner@google.com</a>> wrote:<br class="gmail_msg">
> >> I left out unit tests since we'd essentially be duplicating the unit tests<br class="gmail_msg">
> >> of MemoryBuffer, and because it involves the file system (also this is<br class="gmail_msg">
> >> temporary code until DataBuffer stuff goes away). Lmk if you disagree though<br class="gmail_msg">
> >> On Fri, Feb 24, 2017 at 2:53 AM Pavel Labath via Phabricator<br class="gmail_msg">
> >> <<a href="mailto:reviews@reviews.llvm.org" class="gmail_msg" target="_blank">reviews@reviews.llvm.org</a>> wrote:<br class="gmail_msg">
> >>><br class="gmail_msg">
> >>> labath added a comment.<br class="gmail_msg">
> >>><br class="gmail_msg">
> >>> I am not sure if this is a voting situation, but I agree with what Zachary<br class="gmail_msg">
> >>> said above.<br class="gmail_msg">
> >>><br class="gmail_msg">
> >>> Since we're already speaking about tests, it looks like the new<br class="gmail_msg">
> >>> DataBufferLLVM class could use a unit test or two, just so we get in the<br class="gmail_msg">
> >>> habit of writing those.<br class="gmail_msg">
> >>><br class="gmail_msg">
> >>><br class="gmail_msg">
> >>> <a href="https://reviews.llvm.org/D30054" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D30054</a><br class="gmail_msg">
> >>><br class="gmail_msg">
> >>><br class="gmail_msg">
> >>><br class="gmail_msg">
> >><br class="gmail_msg">
> > _______________________________________________<br class="gmail_msg">
> > lldb-commits mailing list<br class="gmail_msg">
> > <a href="mailto:lldb-commits@lists.llvm.org" class="gmail_msg" target="_blank">lldb-commits@lists.llvm.org</a><br class="gmail_msg">
> > <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br class="gmail_msg">
><br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div>