<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";
        mso-fareast-language:EN-GB;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I will more thoroughly test all different combination on Linux to see how they affect performance. I will let you know what I find although it may be a few
 days. Please also check your patch on OSX to see it does not create any other issue before sending.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Abid<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Ilia K [mailto:ki.stfu@gmail.com]
<br>
<b>Sent:</b> 10 December 2014 09:29<br>
<b>To:</b> Abid, Hafiz<br>
<b>Cc:</b> lldb-commits@cs.uiuc.edu<br>
<b>Subject:</b> Re: [Lldb-commits] [lldb] r223222 - Fix a hang on OSX while executing -exec-run.<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hello Abid,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks again for the fix :)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">As far as I know this needed only on OSX and it isn't required on other platforms. But after it was committed 'lldb-mi --interpreter' began to load cpu over 100%!! It's very bad on my side. And as I understood it happened on Linux too.
 Of course it helped with hangs on OSX, but it made worse for Linux (and OSX). You said that 'select' patch increases time to run test many times, but I didn't face with it on OSX (although I think 'select' shouldn't affect it). I believe that it is necessary
 to revert 'ioctl' patch (to avoid overheads of CPU) and apply 'select' patch to OSX only (by using #ifdef __APPLE__ or by creating separate file).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I can create patch for it if you agree.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Ilia<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Thu, Dec 4, 2014 at 2:04 PM, Abid, Hafiz <<a href="mailto:Hafiz_Abid@mentor.com" target="_blank">Hafiz_Abid@mentor.com</a>> wrote:<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Please send them. I will try.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Abid</span><o:p></o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Ilia
 K [mailto:<a href="mailto:ki.stfu@gmail.com" target="_blank">ki.stfu@gmail.com</a>]
<br>
<b>Sent:</b> 04 December 2014 11:02</span><o:p></o:p></p>
<div>
<div>
<p class="MsoNormal"><br>
<b>To:</b> Abid, Hafiz<br>
<b>Cc:</b> <a href="mailto:lldb-commits@cs.uiuc.edu" target="_blank">lldb-commits@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [Lldb-commits] [lldb] r223222 - Fix a hang on OSX while executing -exec-run.<o:p></o:p></p>
</div>
</div>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Abid,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Thank you.<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I have a few more patches and possible I'll send some of them today. Could you review them too?<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Ilia<o:p></o:p></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On Thu, Dec 4, 2014 at 1:53 PM, Abid, Hafiz <<a href="mailto:Hafiz_Abid@mentor.com" target="_blank">Hafiz_Abid@mentor.com</a>> wrote:<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I tried to remove setbuf() yesterday and it didn't affect, so I think it is not needed. Could you remove code related to setbuf() from my patch yourself?<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Ok I will remove and then commit the patch. If you intend to contribute more patches. I would be
 good to get commit access.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Abid</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Ilia
 K [mailto:<a href="mailto:ki.stfu@gmail.com" target="_blank">ki.stfu@gmail.com</a>]
<br>
<b>Sent:</b> 04 December 2014 10:41</span><o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><br>
<b>To:</b> Abid, Hafiz<br>
<b>Cc:</b> <a href="mailto:lldb-commits@cs.uiuc.edu" target="_blank">lldb-commits@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [Lldb-commits] [lldb] r223222 - Fix a hang on OSX while executing -exec-run.<o:p></o:p></p>
</div>
</div>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Hi Abid,<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">> <span style="font-size:11.5pt;font-family:"Calibri","sans-serif";color:#1F497D"> It is now returning false when ioctl fails</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I think that it's right, because status is unavailable.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">> <span style="font-size:11.5pt;font-family:"Calibri","sans-serif";color:#1F497D">Regarding your question about setbuf, I thought that setting it to null makes ioctl type function
 to return when some input is available and not wait for the new line character</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I realized that setbuf is not needed. As you said, it makes ioctl type function to return when some input is available and not wait for the new line character, but in canonical
 mode, you don't get control back until the new line character had typed.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">> <span style="font-size:11.5pt;font-family:"Calibri","sans-serif";color:#1F497D">Can you try on OSX after removing the setbuf call</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I tried to remove setbuf() yesterday and it didn't affect, so I think it is not needed. Could you remove code related to setbuf() from my patch yourself?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Ilia<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On Thu, Dec 4, 2014 at 1:17 PM, Abid, Hafiz <<a href="mailto:Hafiz_Abid@mentor.com" target="_blank">Hafiz_Abid@mentor.com</a>> wrote:<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Hi Ilia,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks for the patch. It looks much cleaner. I was also not sure how tcgetattr type functions were
 helping with the original fix. Regarding your patch, I only have one comment. It is now returning false when ioctl fails. It can result in lldb-mi quitting. Previously this function was always returning true. I don’t think this is a big deal though.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Regarding your question about setbuf, I thought that setting it to null makes ioctl type function
 to return when some input is available and not wait for the new line character. I may be wrong here too. Can you try on OSX after removing the setbuf call. Does that change the behaviour in any way. Because I cannot see any noticeable difference on Linux.
</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Regards,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Abid</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Ilia
 K [mailto:<a href="mailto:ki.stfu@gmail.com" target="_blank">ki.stfu@gmail.com</a>]
<br>
<b>Sent:</b> 03 December 2014 16:17</span><o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><br>
<b>To:</b> Abid, Hafiz<br>
<b>Cc:</b> <a href="mailto:lldb-commits@cs.uiuc.edu" target="_blank">lldb-commits@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [Lldb-commits] [lldb] r223222 - Fix a hang on OSX while executing -exec-run.<o:p></o:p></p>
</div>
</div>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Hi Abid,<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Sorry for remarks, but there is a one problem with "ioctl" patch: it turns off canonical mode so we can't modify commands on input line correctly :(.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Also I added error checks and moved "setbuf(stdin, NULL)" into Initialize function to avoid ugly in-place initialization using static variable (but, if be honest I don't know why
 we need to disable bufferization before "ioctl" call).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I prepared new patch. Review it please.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Ilia<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On Wed, Dec 3, 2014 at 3:52 PM, Ilia K <<a href="mailto:ki.stfu@gmail.com" target="_blank">ki.stfu@gmail.com</a>> wrote:<o:p></o:p></p>
<p>Thank you<o:p></o:p></p>
<div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On 3 Dec 2014 15:50, "Abid, Hafiz" <<a href="mailto:Hafiz_Abid@mentor.com" target="_blank">Hafiz_Abid@mentor.com</a>> wrote:<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks for catching this. I have removed the extra changes in r223227.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Abid</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Ilia
 K [mailto:<a href="mailto:ki.stfu@gmail.com" target="_blank">ki.stfu@gmail.com</a>]
<br>
<b>Sent:</b> 03 December 2014 12:40<br>
<b>To:</b> Abid, Hafiz<br>
<b>Cc:</b> <a href="mailto:lldb-commits@cs.uiuc.edu" target="_blank">lldb-commits@cs.uiuc.edu</a><br>
<b>Subject:</b> RE: [Lldb-commits] [lldb] r223222 - Fix a hang on OSX while executing -exec-run.</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p>Yes. "select" patch requires extra handling on exit.<o:p></o:p></p>
<p>Thanks, <br>
Ilia<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On 3 Dec 2014 15:37, "Abid, Hafiz" <<a href="mailto:Hafiz_Abid@mentor.com" target="_blank">Hafiz_Abid@mentor.com</a>> wrote:<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">You mean that just the change in ‘InputAvailable’ was needed? Rest of the changes were required with
 ‘select’.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Regards,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Abid</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> </span><o:p></o:p></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Ilia
 K [mailto:<a href="mailto:ki.stfu@gmail.com" target="_blank">ki.stfu@gmail.com</a>]
<br>
<b>Sent:</b> 03 December 2014 10:59<br>
<b>To:</b> Abid, Hafiz<br>
<b>Cc:</b> <a href="mailto:lldb-commits@cs.uiuc.edu" target="_blank">lldb-commits@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [Lldb-commits] [lldb] r223222 - Fix a hang on OSX while executing -exec-run.</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Hello Abid,<o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Thanks for commit :)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">But "ioctl" patch requires less changes than "select" version of this patch. Could you commit another patch to revert all unnecessary changes?<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Ilia<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On Wed, Dec 3, 2014 at 1:23 PM, Hafiz Abid Qadeer <<a href="mailto:hafiz_abid@mentor.com" target="_blank">hafiz_abid@mentor.com</a>> wrote:<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Author: abidh<br>
Date: Wed Dec  3 04:23:06 2014<br>
New Revision: 223222<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=223222&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=223222&view=rev</a><br>
Log:<br>
Fix a hang on OSX while executing -exec-run.<br>
Now we wait for input to become available before blocking in fgets.<br>
More details on problem can be found in<br>
<a href="http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20141201/014290.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/lldb-commits/Week-of-Mon-20141201/014290.html</a><br>
<br>
Patch from <a href="mailto:dawn@burble.org" target="_blank">dawn@burble.org</a>.<br>
<br>
<br>
Modified:<br>
    lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp<br>
    lldb/trunk/tools/lldb-mi/MICmnStreamStdin.h<br>
    lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.cpp<br>
    lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.h<br>
    lldb/trunk/tools/lldb-mi/MIDriver.cpp<br>
<br>
Modified: lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp?rev=223222&r1=223221&r2=223222&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp?rev=223222&r1=223221&r2=223222&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp (original)<br>
+++ lldb/trunk/tools/lldb-mi/MICmnStreamStdin.cpp Wed Dec  3 04:23:06 2014<br>
@@ -434,3 +434,16 @@ CMICmnStreamStdin::SetOSStdinHandler(IOS<br>
<br>
     return MIstatus::success;<br>
 }<br>
+<br>
+//++ ------------------------------------------------------------------------------------<br>
+// Details: Do some actions before exiting.<br>
+// Type:    Method.<br>
+// Args:    None.<br>
+// Return:  None.<br>
+// Throws:  None.<br>
+//--<br>
+void<br>
+CMICmnStreamStdin::OnExitHandler(void)<br>
+{<br>
+    m_pStdinReadHandler->InterruptReadLine();<br>
+}<br>
<br>
Modified: lldb/trunk/tools/lldb-mi/MICmnStreamStdin.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdin.h?rev=223222&r1=223221&r2=223222&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdin.h?rev=223222&r1=223221&r2=223222&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/tools/lldb-mi/MICmnStreamStdin.h (original)<br>
+++ lldb/trunk/tools/lldb-mi/MICmnStreamStdin.h Wed Dec  3 04:23:06 2014<br>
@@ -66,6 +66,7 @@ class CMICmnStreamStdin : public CMICmnB<br>
       public:<br>
         virtual bool InputAvailable(bool &vwbAvail) = 0;<br>
         virtual const MIchar *ReadLine(CMIUtilString &vwErrMsg) = 0;<br>
+        virtual void InterruptReadLine(void){};<br>
<br>
         /* dtor */ virtual ~IOSStdinHandler(void){};<br>
     };<br>
@@ -82,6 +83,7 @@ class CMICmnStreamStdin : public CMICmnB<br>
     void SetCtrlCHit(void);<br>
     bool SetVisitor(IStreamStdin &vrVisitor);<br>
     bool SetOSStdinHandler(IOSStdinHandler &vrHandler);<br>
+    void OnExitHandler(void);<br>
<br>
     // Overridden:<br>
   public:<br>
<br>
Modified: lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.cpp?rev=223222&r1=223221&r2=223222&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.cpp?rev=223222&r1=223221&r2=223222&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.cpp (original)<br>
+++ lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.cpp Wed Dec  3 04:23:06 2014<br>
@@ -22,7 +22,9 @@<br>
 // Third Party Headers:<br>
 #if !defined(_MSC_VER)<br>
 #include <sys/select.h><br>
+#include <unistd.h><br>
 #include <termios.h><br>
+#include <sys/ioctl.h><br>
 #endif              // !defined( _MSC_VER )<br>
 #include <string.h> // For std::strerror()<br>
<br>
@@ -153,30 +155,29 @@ CMICmnStreamStdinLinux::Shutdown(void)<br>
 bool<br>
 CMICmnStreamStdinLinux::InputAvailable(bool &vwbAvail)<br>
 {<br>
-    /* AD: Not used ATM but could come in handy just in case we need to do<br>
-           this, poll for input<br>
-<br>
-            static const int STDIN = 0;<br>
-        static bool bInitialized = false;<br>
-<br>
-        if( !bInitialized )<br>
-            {<br>
-            // Use termios to turn off line buffering<br>
-            ::termios term;<br>
-            ::tcgetattr( STDIN, &term );<br>
-            ::term.c_lflag &= ~ICANON;<br>
-            ::tcsetattr( STDIN, TCSANOW, &term );<br>
-            ::setbuf( stdin, NULL );<br>
-            bInitialized = true;<br>
-        }<br>
-<br>
-        int nBytesWaiting;<br>
-        ::ioctl( STDIN, FIONREAD, &nBytesWaiting );<br>
-        vwbAvail = (nBytesWaiting > 0);<br>
-<br>
-            return MIstatus::success;<br>
-    */<br>
-<br>
+#if !defined(_WIN32)<br>
+    // The code below is needed on OSX where lldb-mi hangs when doing -exec-run.<br>
+    // The hang seems to come from calling fgets and fileno from different thread.<br>
+    // Although this problem was not observed on Linux.<br>
+    // A solution based on 'select' was also proposed but it seems to slow things down<br>
+    // a lot.<br>
+    static bool bInitialized = false;<br>
+<br>
+    if (!bInitialized)<br>
+    {<br>
+        // Use termios to turn off line buffering<br>
+        ::termios term;<br>
+        ::tcgetattr(STDIN_FILENO, &term);<br>
+        term.c_lflag &= ~ICANON;<br>
+        ::tcsetattr(STDIN_FILENO, TCSANOW, &term);<br>
+        ::setbuf(stdin, NULL);<br>
+        bInitialized = true;<br>
+    }<br>
+<br>
+    int nBytesWaiting;<br>
+    ::ioctl(STDIN_FILENO, FIONREAD, &nBytesWaiting);<br>
+    vwbAvail = (nBytesWaiting > 0);<br>
+#endif<br>
     return MIstatus::success;<br>
 }<br>
<br>
@@ -213,3 +214,16 @@ CMICmnStreamStdinLinux::ReadLine(CMIUtil<br>
<br>
     return pText;<br>
 }<br>
+<br>
+//++ ------------------------------------------------------------------------------------<br>
+// Details: Interrupt current and prevent new ReadLine operations.<br>
+// Type:    Method.<br>
+// Args:    None.<br>
+// Return:  None.<br>
+// Throws:  None.<br>
+//--<br>
+void<br>
+CMICmnStreamStdinLinux::InterruptReadLine(void)<br>
+{<br>
+    fclose(stdin);<br>
+}<br>
<br>
Modified: lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.h?rev=223222&r1=223221&r2=223222&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.h?rev=223222&r1=223221&r2=223222&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.h (original)<br>
+++ lldb/trunk/tools/lldb-mi/MICmnStreamStdinLinux.h Wed Dec  3 04:23:06 2014<br>
@@ -51,6 +51,7 @@ class CMICmnStreamStdinLinux : public CM<br>
     // From CMICmnStreamStdin::IOSpecificReadStreamStdin<br>
     virtual bool InputAvailable(bool &vwbAvail);<br>
     virtual const MIchar *ReadLine(CMIUtilString &vwErrMsg);<br>
+    virtual void InterruptReadLine(void);<br>
<br>
     // Methods:<br>
   private:<br>
<br>
Modified: lldb/trunk/tools/lldb-mi/MIDriver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIDriver.cpp?rev=223222&r1=223221&r2=223222&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MIDriver.cpp?rev=223222&r1=223221&r2=223222&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/tools/lldb-mi/MIDriver.cpp (original)<br>
+++ lldb/trunk/tools/lldb-mi/MIDriver.cpp Wed Dec  3 04:23:06 2014<br>
@@ -1075,6 +1075,7 @@ CMIDriver::SetExitApplicationFlag(const<br>
     {<br>
         CMIUtilThreadLock lock(m_threadMutex);<br>
         m_bExitApp = true;<br>
+        m_rStdin.OnExitHandler();<br>
         return;<br>
     }<br>
<br>
@@ -1089,6 +1090,7 @@ CMIDriver::SetExitApplicationFlag(const<br>
     }<br>
<br>
     m_bExitApp = true;<br>
+    m_rStdin.OnExitHandler();<br>
 }<br>
<br>
 //++ ------------------------------------------------------------------------------------<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@cs.uiuc.edu" target="_blank">lldb-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits</a><o:p></o:p></p>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>