<div dir="ltr">Hi Abhishek,<div><br></div><div>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?</div><div><br></div><div>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.</div><div><br></div><div>Thanks,</div><div>Tamas</div></div><br><div class="gmail_quote"><div dir="ltr">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:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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" rel="noreferrer" 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" rel="noreferrer" 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" rel="noreferrer" 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" rel="noreferrer" 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" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div>