<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 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        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;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
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-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Hi Tamas<o:p></o:p></span></a></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">Yes, it was a bug in clang that I had submitted some months ago (ID: 23491) and it was fixed. But the fix is not present in clang 3.5/3.6. Hence, the failure
 is occurring.<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 & Regards<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Abhishek Aggarwal<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"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Tamas Berghammer [mailto:tberghammer@google.com]
<br>
<b>Sent:</b> Wednesday, December 2, 2015 2:41 PM<br>
<b>To:</b> Aggarwal, Abhishek A <abhishek.a.aggarwal@intel.com>; lldb-commits@lists.llvm.org<br>
<b>Subject:</b> Re: [Lldb-commits] [lldb] r254499 - PTRACE ABI to read FXSAVE area for 32-bit inferior<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hi Abhishek,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">After this change TestReturnValue.py is failing on Linux with i386 inferior when compiling the inferior with clang-3.5 (it passes with gcc and with ToT clang). I marked the test XFAIL for that specific configuration to get the buildbot
 green but can you take a look?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">My suspicion is that clang 3.5 and 3.6 uses an incorrect ABI for returning small structs from functions (returning it in register instead of in memory pointed by a register) what causing the issue but I am not certain.<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">Tamas<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Wed, Dec 2, 2015 at 9:43 AM Abhishek Aggarwal via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Author: abhishek<br>
Date: Wed Dec  2 03:40:17 2015<br>
New Revision: 254499<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=254499&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=254499&view=rev</a><br>
Log:<br>
PTRACE ABI to read FXSAVE area for 32-bit inferior<br>
<br>
Summary:<br>
 - Problem occurs when:<br>
    -- 32-bit inferiors run on x86_32 machine and<br>
       the architecture doesn't have AVX feature<br>
<br>
    -- This causes FPRType to be set to eFPRTypeFXSAVE<br>
<br>
    -- PTRACE_GETFPREGS was being used to read FXSAVE area<br>
<br>
    -- For 32-bit inferiors running on x86_32 machine,<br>
       PTRACE_GETFPREGS reads FSAVE area and not FXSAVE area<br>
<br>
 - Changed ptrace API to PTRACE_GETREGSET for 32-bit inferiors<br>
    -- This reads FPR data in FXSAVE format.<br>
    -- For 64-bit inferiors, no change has been made.<br>
<br>
 - Modified XFAIL for TestReturnValue.py<br>
    -- Earlier, this test was passing for Linux OS<br>
    -- Now, it passes for Android OS as well<br>
<br>
Change-Id: Ieed72bc969b79516fc7b263b32493aa1e7a1a2ac<br>
Signed-off-by: Abhishek Aggarwal <<a href="mailto:abhishek.a.aggarwal@intel.com" target="_blank">abhishek.a.aggarwal@intel.com</a>><br>
<br>
Reviewers: ovyalov, jingham, lldb-commits, tberghammer, labath<br>
<br>
Subscribers: jevinskie, labath, tberghammer, danalbert<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D15042" target="_blank">http://reviews.llvm.org/D15042</a><br>
<br>
Modified:<br>
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py<br>
    lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp<br>
<br>
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py?rev=254499&r1=254498&r2=254499&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py?rev=254499&r1=254498&r2=254499&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py (original)<br>
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/return-value/TestReturnValue.py Wed Dec  2 03:40:17 2015<br>
@@ -16,7 +16,7 @@ class ReturnValueTestCase(TestBase):<br>
<br>
     mydir = TestBase.compute_mydir(__file__)<br>
<br>
-    @expectedFailurei386<br>
+    @expectedFailureAll(oslist=["macosx","freebsd"], archs=["i386"])<br>
     @expectedFailureWindows("<a href="http://llvm.org/pr24778" target="_blank">llvm.org/pr24778</a>")<br>
     @add_test_categories(['pyapi'])<br>
     def test_with_python(self):<br>
<br>
Modified: lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp?rev=254499&r1=254498&r2=254499&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp?rev=254499&r1=254498&r2=254499&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp (original)<br>
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp Wed Dec  2 03:40:17 2015<br>
@@ -327,6 +327,9 @@ namespace<br>
 #ifndef NT_X86_XSTATE<br>
 #define NT_X86_XSTATE 0x202<br>
 #endif<br>
+#ifndef NT_PRXFPREG<br>
+#define NT_PRXFPREG 0x46e62b7f<br>
+#endif<br>
<br>
 NativeRegisterContextLinux*<br>
 NativeRegisterContextLinux::CreateHostNativeRegisterContextLinux(const ArchSpec& target_arch,<br>
@@ -832,6 +835,7 @@ NativeRegisterContextLinux_x86_64::IsGPR<br>
 NativeRegisterContextLinux_x86_64::FPRType<br>
 NativeRegisterContextLinux_x86_64::GetFPRType () const<br>
 {<br>
+    Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS));<br>
     if (m_fpr_type == eFPRTypeNotValid)<br>
     {<br>
         // TODO: Use assembly to call cpuid on the inferior and query ebx or ecx.<br>
@@ -842,9 +846,15 @@ NativeRegisterContextLinux_x86_64::GetFP<br>
         {<br>
             // Fall back to general floating point with no AVX support.<br>
             m_fpr_type = eFPRTypeFXSAVE;<br>
+<br>
+            // Check if FXSAVE area can be read.<br>
+            if (const_cast<NativeRegisterContextLinux_x86_64*>(this)->ReadFPR().Fail())<br>
+            {<br>
+                if (log)<br>
+                    log->Printf("NativeRegisterContextLinux_x86_64::%s ptrace APIs failed to read XSAVE/FXSAVE area", __FUNCTION__);<br>
+            }<br>
         }<br>
     }<br>
-<br>
     return m_fpr_type;<br>
 }<br>
<br>
@@ -868,10 +878,24 @@ Error<br>
 NativeRegisterContextLinux_x86_64::WriteFPR()<br>
 {<br>
     const FPRType fpr_type = GetFPRType ();<br>
+    const lldb_private::ArchSpec& target_arch = GetRegisterInfoInterface().GetTargetArchitecture();<br>
     switch (fpr_type)<br>
     {<br>
     case FPRType::eFPRTypeFXSAVE:<br>
-        return NativeRegisterContextLinux::WriteFPR();<br>
+        // For 32-bit inferiors on x86_32/x86_64 architectures,<br>
+        // FXSAVE area can be written using PTRACE_SETREGSET ptrace api<br>
+        // For 64-bit inferiors on x86_64 architectures,<br>
+        // FXSAVE area can be written using PTRACE_SETFPREGS ptrace api<br>
+        switch (target_arch.GetMachine ())<br>
+        {<br>
+            case llvm::Triple::x86:<br>
+                return WriteRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave), NT_PRXFPREG);<br>
+            case llvm::Triple::x86_64:<br>
+                return NativeRegisterContextLinux::WriteFPR();<br>
+            default:<br>
+                assert(false && "Unhandled target architecture.");<br>
+                break;<br>
+        }<br>
     case FPRType::eFPRTypeXSAVE:<br>
         return WriteRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave), NT_X86_XSTATE);<br>
     default:<br>
@@ -980,10 +1004,24 @@ Error<br>
 NativeRegisterContextLinux_x86_64::ReadFPR ()<br>
 {<br>
     const FPRType fpr_type = GetFPRType ();<br>
+    const lldb_private::ArchSpec& target_arch = GetRegisterInfoInterface().GetTargetArchitecture();<br>
     switch (fpr_type)<br>
     {<br>
     case FPRType::eFPRTypeFXSAVE:<br>
-        return NativeRegisterContextLinux::ReadFPR();<br>
+        // For 32-bit inferiors on x86_32/x86_64 architectures,<br>
+        // FXSAVE area can be read using PTRACE_GETREGSET ptrace api<br>
+        // For 64-bit inferiors on x86_64 architectures,<br>
+        // FXSAVE area can be read using PTRACE_GETFPREGS ptrace api<br>
+        switch (target_arch.GetMachine ())<br>
+        {<br>
+            case llvm::Triple::x86:<br>
+                return ReadRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave), NT_PRXFPREG);<br>
+            case llvm::Triple::x86_64:<br>
+                return NativeRegisterContextLinux::ReadFPR();<br>
+            default:<br>
+                assert(false && "Unhandled target architecture.");<br>
+                break;<br>
+        }<br>
     case FPRType::eFPRTypeXSAVE:<br>
         return ReadRegisterSet(&m_iovec, sizeof(m_fpr.xstate.xsave), NT_X86_XSTATE);<br>
     default:<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><o:p></o:p></p>
</blockquote>
</div>
</div>
<p><font style="font-size: 9px;">Intel Deutschland GmbH<br>
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany<br>
Tel: +49 89 99 8853-0, www.intel.de<br>
Managing Directors: Christin Eisenschmid, Christian Lamprechter<br>
Chairperson of the Supervisory Board: Nicole Lau<br>
Registered Office: Munich<br>
Commercial Register: Amtsgericht Muenchen HRB 186928</font><br>
</p>
</body>
</html>