<div dir="ltr">I see. In the future in this kind of situation could you mention in the commit message what test this fixes. For example, "This fixes <span style="font-size:13px;line-height:19.5px">TestRegisters.py on FreeBSD".</span><div><span style="line-height:19.5px"><br></span></div><div><span style="line-height:19.5px"><br></span><div class="gmail_quote"><div dir="ltr">On Tue, Oct 6, 2015 at 7:59 AM Aggarwal, Abhishek A <<a href="mailto:abhishek.a.aggarwal@intel.com" target="_blank">abhishek.a.aggarwal@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><a name="msg-f:1514298106697097813_msg-f:1514294304080698247__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">I had submitted a patch for the Bug 24457 which is similar kind of bug but on Linux x86_64 Platform. There, I had submitted a new test
to reproduce this issue. The test is already there in public repository. Since, the same test goes for FreeBSD also therefore I didn’t need to write a new one.<u></u><u></u></span></a></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d">-Thanks<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d"><u></u> <u></u></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"> Zachary Turner [mailto:<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>]
<br>
<b>Sent:</b> Tuesday, October 6, 2015 4:53 PM<br>
<b>To:</b> Aggarwal, Abhishek A; <a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
<b>Subject:</b> Re: [Lldb-commits] [lldb] r249379 - Bug 25050: X87 FPU Special Purpose Registers<u></u><u></u></span></p></div></div><div lang="EN-US" link="blue" vlink="purple"><div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Please don't submit CLs like this without a test in the future. This should be testable by writing some assembly to move a value into an FPU register, setting a breakpoint, then querying the register values. Can you submit this as a followup?<u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Tue, Oct 6, 2015 at 12:05 AM Abhishek Aggarwal via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a>> wrote:<u></u><u></u></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: Tue Oct 6 02:04:03 2015<br>
New Revision: 249379<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=249379&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=249379&view=rev</a><br>
Log:<br>
Bug 25050: X87 FPU Special Purpose Registers<br>
<br>
Summary:<br>
- For x86_64-FreeBSD Platform:<br>
-- LLDB now provides correct values of X87 FPU<br>
Special Purpose Registers like fstat, ftag, fctrl etc..<br>
<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: emaste, mikesart, clayborg<br>
<br>
Subscribers: emaste<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D13434" target="_blank">http://reviews.llvm.org/D13434</a><br>
<br>
Modified:<br>
lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp<br>
lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h<br>
<br>
Modified: lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp?rev=249379&r1=249378&r2=249379&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp?rev=249379&r1=249378&r2=249379&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp (original)<br>
+++ lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.cpp Tue Oct 6 02:04:03 2015<br>
@@ -58,6 +58,9 @@ RegisterContextPOSIXProcessMonitor_x86_6<br>
lldb_private::RegisterInfoInterface *register_info)<br>
: RegisterContextPOSIX_x86(thread, concrete_frame_idx, register_info)<br>
{<br>
+ // Store byte offset of fctrl (i.e. first register of FPR) wrt 'UserArea'<br>
+ const RegisterInfo *reg_info_fctrl = GetRegisterInfoByName("fctrl");<br>
+ m_fctrl_offset_in_userarea = reg_info_fctrl->byte_offset;<br>
}<br>
<br>
ProcessMonitor &<br>
@@ -254,8 +257,15 @@ RegisterContextPOSIXProcessMonitor_x86_6<br>
}<br>
<br>
// Get pointer to m_fpr.xstate.fxsave variable and set the data from it.<br>
- assert (reg_info->byte_offset < sizeof(m_fpr));<br>
- uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset;<br>
+ // Byte offsets of all registers are calculated wrt 'UserArea' structure.<br>
+ // However, ReadFPR() reads fpu registers {using ptrace(PT_GETFPREGS,..)}<br>
+ // and stores them in 'm_fpr' (of type FPR structure). To extract values of fpu<br>
+ // registers, m_fpr should be read at byte offsets calculated wrt to FPR structure.<br>
+<br>
+ // Since, FPR structure is also one of the member of UserArea structure.<br>
+ // byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) - byte_offset(fctrl wrt UserArea)<br>
+ assert ( (reg_info->byte_offset - m_fctrl_offset_in_userarea) < sizeof(m_fpr));<br>
+ uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset - m_fctrl_offset_in_userarea;<br>
switch (reg_info->byte_size)<br>
{<br>
case 2:<br>
@@ -308,8 +318,15 @@ RegisterContextPOSIXProcessMonitor_x86_6<br>
else<br>
{<br>
// Get pointer to m_fpr.xstate.fxsave variable and set the data to it.<br>
- assert (reg_info->byte_offset < sizeof(m_fpr));<br>
- uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset;<br>
+ // Byte offsets of all registers are calculated wrt 'UserArea' structure.<br>
+ // However, WriteFPR() takes m_fpr (of type FPR structure) and writes only fpu<br>
+ // registers using ptrace(PT_SETFPREGS,..) API. Hence fpu registers should<br>
+ // be written in m_fpr at byte offsets calculated wrt FPR structure.<br>
+<br>
+ // Since, FPR structure is also one of the member of UserArea structure.<br>
+ // byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) - byte_offset(fctrl wrt UserArea)<br>
+ assert ( (reg_info->byte_offset - m_fctrl_offset_in_userarea) < sizeof(m_fpr));<br>
+ uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset - m_fctrl_offset_in_userarea;<br>
switch (reg_info->byte_size)<br>
{<br>
case 2:<br>
<br>
Modified: lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h?rev=249379&r1=249378&r2=249379&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h?rev=249379&r1=249378&r2=249379&view=diff</a><br>
==============================================================================<br>
--- lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h (original)<br>
+++ lldb/trunk/source/Plugins/Process/FreeBSD/RegisterContextPOSIXProcessMonitor_x86.h Tue Oct 6 02:04:03 2015<br>
@@ -91,6 +91,7 @@ protected:<br>
private:<br>
ProcessMonitor &<br>
GetMonitor();<br>
+ uint32_t m_fctrl_offset_in_userarea; // Offset of 'fctrl' in 'UserArea' Structure<br>
};<br>
<br>
#endif<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><u></u><u></u></p>
</blockquote>
</div>
</div></div><div lang="EN-US" link="blue" vlink="purple"><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, <a href="http://www.intel.de" target="_blank">www.intel.de</a><br>
Managing Directors: Christin Eisenschmid, Prof. Dr. Hermann Eul<br>
Chairperson of the Supervisory Board: Tiffany Doon Silva<br>
Registered Office: Munich<br>
Commercial Register: Amtsgericht Muenchen HRB 186928</font><br>
</p></div>
</blockquote></div></div></div>