<a href="http://reviews.llvm.org">http://reviews.llvm.org</a>. Create an account there and upload patch<br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 17, 2016 at 5:15 PM Eugene Birukov <<a href="mailto:eugenebi@hotmail.com">eugenebi@hotmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr" class="gmail_msg">
<div id="m_4436686286783168260divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif" class="gmail_msg">
<p class="gmail_msg">Sorry for noob's question: what is "phabricator"? </p>
<p class="gmail_msg">Sure, I will do it as soon as I understand what you want me to do :)</p>
<p class="gmail_msg"><br class="gmail_msg">
</p>
<div id="m_4436686286783168260Signature" class="gmail_msg">
<p class="gmail_msg">Sent from <a href="http://aka.ms/weboutlook" id="m_4436686286783168260LPNoLP" class="gmail_msg" target="_blank">Outlook</a><br class="gmail_msg">
</p>
</div>
<br class="gmail_msg">
<br class="gmail_msg">
<div style="color:rgb(0,0,0)" class="gmail_msg">
<hr style="display:inline-block;width:98%" class="gmail_msg">
<div id="m_4436686286783168260divRplyFwdMsg" dir="ltr" class="gmail_msg"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt" class="gmail_msg"><b class="gmail_msg">From:</b> Zachary Turner <<a href="mailto:zturner@google.com" class="gmail_msg" target="_blank">zturner@google.com</a>><br class="gmail_msg">
<b class="gmail_msg">Sent:</b> Monday, October 17, 2016 5:01 PM<br class="gmail_msg">
<b class="gmail_msg">To:</b> Eugene Birukov; Greg Clayton</font></div></div></div></div><div dir="ltr" class="gmail_msg"><div id="m_4436686286783168260divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif" class="gmail_msg"><div style="color:rgb(0,0,0)" class="gmail_msg"><div id="m_4436686286783168260divRplyFwdMsg" dir="ltr" class="gmail_msg"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt" class="gmail_msg"><br class="gmail_msg">
<b class="gmail_msg">Cc:</b> LLDB<br class="gmail_msg">
<b class="gmail_msg">Subject:</b> Re: [lldb-dev] File::Read does not read everything</font></div></div></div></div><div dir="ltr" class="gmail_msg"><div id="m_4436686286783168260divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif" class="gmail_msg"><div style="color:rgb(0,0,0)" class="gmail_msg">
<div class="gmail_msg">
<div dir="ltr" class="gmail_msg">Can you upload a diff (with context) to phabricator and add lldb-commits as a subscriber and myself / Greg as reviewers?</div>
<br class="gmail_msg">
<div class="gmail_quote gmail_msg">
<div dir="ltr" class="gmail_msg">On Mon, Oct 17, 2016 at 4:59 PM Eugene Birukov via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" class="gmail_msg" target="_blank">lldb-dev@lists.llvm.org</a>> wrote:<br class="gmail_msg">
</div>
<blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr" class="gmail_msg">
<div id="m_4436686286783168260m_7052815235107701521divtagdefaultwrapper" class="gmail_msg" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif">
<p class="gmail_msg">Here is what I am running now:</p>
<p class="gmail_msg"><br class="gmail_msg">
</p>
<p class="gmail_msg"></p>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">diff --git a/source/Host/common/File.cpp b/source/Host/common/File.cpp</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">index 89587a9..a4ac25e 100644</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">--- a/source/Host/common/File.cpp</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+++ b/source/Host/common/File.cpp</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">@@ -771,21 +771,34 @@ File::Read (void *buf, size_t &num_bytes, off_t &offset)</span></div>
</div>
</div>
<div dir="ltr" class="gmail_msg">
<div id="m_4436686286783168260m_7052815235107701521divtagdefaultwrapper" class="gmail_msg" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif">
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt"> int fd = GetDescriptor();</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt"> if (fd != kInvalidDescriptor)</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt"> {</span></div>
</div>
</div>
<div dir="ltr" class="gmail_msg">
<div id="m_4436686286783168260m_7052815235107701521divtagdefaultwrapper" class="gmail_msg" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif">
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">- ssize_t bytes_read = -1;</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">- do</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ size_t bytes_left = num_bytes;</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ num_bytes = 0;</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ char *pos = (char*)buf;</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ while (bytes_left > 0)</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt"> {</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">- bytes_read = ::pread (fd, buf, num_bytes, offset);</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">- } while (bytes_read < 0 && errno == EINTR);</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ ssize_t bytes_read = -1;</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ do</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ {</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ bytes_read = ::pread (fd, pos, bytes_left, offset);</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ } while (bytes_read < 0 && errno == EINTR);</span></div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">- if (bytes_read < 0)</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">- {</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">- num_bytes = 0;</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">- error.SetErrorToErrno();</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">- }</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">- else</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">- {</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">- offset += bytes_read;</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">- num_bytes = bytes_read;</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ if (bytes_read < 0)</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ {</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ num_bytes = 0;</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ error.SetErrorToErrno();</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ break;</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ }</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ else if (bytes_read == 0)</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ {</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ break;</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ }</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ else</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ {</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ offset += bytes_read;</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ num_bytes += bytes_read;</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ bytes_left -= bytes_read;</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ pos += bytes_read;</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt">+ }</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt"> }</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt"> }</span></div>
<div class="gmail_msg"><span class="gmail_msg" style="font-family:"Courier New",monospace;font-size:9pt"> else</span></div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<br class="gmail_msg">
<p class="gmail_msg"></p>
<p class="gmail_msg"><br class="gmail_msg">
</p>
<div id="m_4436686286783168260m_7052815235107701521Signature" class="gmail_msg">
<p class="gmail_msg">Sent from <a href="http://aka.ms/weboutlook" id="m_4436686286783168260m_7052815235107701521LPNoLP" class="gmail_msg" target="_blank">
Outlook</a><br class="gmail_msg">
</p>
</div>
<br class="gmail_msg">
<br class="gmail_msg">
<div class="gmail_msg" style="color:rgb(0,0,0)">
<div class="gmail_msg">
<hr class="gmail_msg" style="display:inline-block;width:98%">
<div id="m_4436686286783168260m_7052815235107701521x_divRplyFwdMsg" dir="ltr" class="gmail_msg"><font face="Calibri, sans-serif" color="#000000" class="gmail_msg" style="font-size:11pt"><b class="gmail_msg">From:</b> Greg Clayton <<a href="mailto:gclayton@apple.com" class="gmail_msg" target="_blank">gclayton@apple.com</a>><br class="gmail_msg">
<b class="gmail_msg">Sent:</b> Monday, October 17, 2016 12:39 PM<br class="gmail_msg">
<b class="gmail_msg">To:</b> Eugene Birukov<br class="gmail_msg">
<b class="gmail_msg">Cc:</b> LLDB<br class="gmail_msg">
<b class="gmail_msg">Subject:</b> Re: [lldb-dev] File::Read does not read everything</font>
<div class="gmail_msg"> </div>
</div>
</div>
</div>
</div>
</div>
<div dir="ltr" class="gmail_msg">
<div id="m_4436686286783168260m_7052815235107701521divtagdefaultwrapper" class="gmail_msg" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif">
<div class="gmail_msg" style="color:rgb(0,0,0)"><font size="2" class="gmail_msg"><span class="gmail_msg" style="font-size:10pt">
<div class="m_4436686286783168260m_7052815235107701521PlainText gmail_msg">It is probably best to make the code loop as long as "bytes_reads > 0" and we haven't read "num_bytes" yet. The darwin kernel has a INT32_MAX read size which gets set to MAX_READ_SIZE, but we need to do
that because if you try to read more than that it reads nothing. So MAX_READ_SIZE is more for the case where the read will outright fail if given a byte size that is too large. Feel free to submit a patch that can keep calling pread correctly in a loop as
long as bytes_read > 0.<br class="gmail_msg">
<br class="gmail_msg">
Greg<br class="gmail_msg">
<br class="gmail_msg">
> On Oct 17, 2016, at 12:20 PM, Eugene Birukov via lldb-dev <<a href="mailto:lldb-dev@lists.llvm.org" class="gmail_msg" target="_blank">lldb-dev@lists.llvm.org</a>> wrote:<br class="gmail_msg">
> <br class="gmail_msg">
> Hello,<br class="gmail_msg">
> <br class="gmail_msg">
> I am using LLDB 3.9 on Linux Ubuntu. I am loading a 5GiB core which is located on Windows file share mounted on Linux via mount.cifs. I see that we successfully allocated memory and are trying to fill it in one read. Unfortunately pread returns 2GiB and we
never check for short read here.<br class="gmail_msg">
> <br class="gmail_msg">
> I think we could combine this code with previous block "#if defined (MAX_READ_SIZE)" if we simply check for short read here (bytes_read too small) and loop until all the buffer is filled.<br class="gmail_msg">
> <br class="gmail_msg">
> Thanks,<br class="gmail_msg">
> Eugene<br class="gmail_msg">
> <br class="gmail_msg">
> #ifndef _WIN32<br class="gmail_msg">
> int fd = GetDescriptor();<br class="gmail_msg">
> if (fd != kInvalidDescriptor)<br class="gmail_msg">
> {<br class="gmail_msg">
> ssize_t bytes_read = -1;<br class="gmail_msg">
> do<br class="gmail_msg">
> {<br class="gmail_msg">
> bytes_read = ::pread (fd, buf, num_bytes, offset);<br class="gmail_msg">
> } while (bytes_read < 0 && errno == EINTR);<br class="gmail_msg">
> <br class="gmail_msg">
> if (bytes_read < 0)<br class="gmail_msg">
> {<br class="gmail_msg">
> num_bytes = 0;<br class="gmail_msg">
> error.SetErrorToErrno();<br class="gmail_msg">
> }<br class="gmail_msg">
> else<br class="gmail_msg">
> {<br class="gmail_msg">
> offset += bytes_read;<br class="gmail_msg">
> num_bytes = bytes_read;<br class="gmail_msg">
> }<br class="gmail_msg">
> }<br class="gmail_msg">
> <br class="gmail_msg">
> Sent from Outlook<br class="gmail_msg">
> _______________________________________________<br class="gmail_msg">
> lldb-dev mailing list<br class="gmail_msg">
> <a href="mailto:lldb-dev@lists.llvm.org" class="gmail_msg" target="_blank">lldb-dev@lists.llvm.org</a><br class="gmail_msg">
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" class="gmail_msg" target="_blank">
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev</a><br class="gmail_msg">
<br class="gmail_msg">
</div>
</span></font></div>
</div>
</div>
_______________________________________________<br class="gmail_msg">
lldb-dev mailing list<br class="gmail_msg">
<a href="mailto:lldb-dev@lists.llvm.org" class="gmail_msg" target="_blank">lldb-dev@lists.llvm.org</a><br class="gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev</a><br class="gmail_msg">
</blockquote>
</div>
</div>
</div></div></div></blockquote></div>