Re: [Lldb-commits] [lldb] r246955 - Bug 24457 - X87 FPU Special Purpose Registers

2015-09-07 Thread Aggarwal, Abhishek A via lldb-commits
Hi 

Thanks a lot for pointing out. There was a problem with the compilation of the 
inferior with clang and hence, the absence of the inferior's executable was 
causing the failure of the test for clang compiler. I fixed it and will soon 
upstream the change. 

Thanks & Regards
Abhishek Aggarwal

-Original Message-
From: Pavel Labath [mailto:lab...@google.com] 
Sent: Monday, September 7, 2015 10:58 AM
To: Aggarwal, Abhishek A
Cc: lldb-commits@lists.llvm.org
Subject: Re: [Lldb-commits] [lldb] r246955 - Bug 24457 - X87 FPU Special 
Purpose Registers

Hi,

this new test fails when the inferior is compiled with clang, as the produced 
line tables are not what you expect. I have marked it as XFAIL to get the bots 
green, but it would be great if we could write it in a way that works on clang 
as well.

pl


On 7 September 2015 at 08:40, Abhishek Aggarwal via lldb-commits 
 wrote:
> Author: abhishek
> Date: Mon Sep  7 02:40:16 2015
> New Revision: 246955
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246955&view=rev
> Log:
> Bug 24457 - X87 FPU Special Purpose Registers
>
> Summary:
>   - For 'register read --all' command on x86_64-Linux Platform:
>
>   -- Provide correct values of X87 FPU Special Purpose Registers
>   -- Both 32-bit & 64-bit inferiors give correct values on this
>  Platform
>
>   - Added a Test Vector:
>   -- To verify the expected behaviour of the command
>
> Signed-off-by: Abhishek Aggarwal 
>
> Reviewers: ashok.thirumurthi, granata.enrico, tfiala, clayborg
>
> Differential Revision: http://reviews.llvm.org/D12592
>
> Added:
> lldb/trunk/test/functionalities/register/a.cpp   (with props)
> Modified:
> 
> lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp 
>   (contents, props changed)
> 
> lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
> lldb/trunk/test/functionalities/register/Makefile   (contents, props 
> changed)
> lldb/trunk/test/functionalities/register/TestRegisters.py   (contents, 
> props changed)
> lldb/trunk/test/functionalities/register/main.cpp   (contents, props 
> changed)
>
> Modified: 
> lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86
> _64.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/
> Linux/NativeRegisterContextLinux_x86_64.cpp?rev=246955&r1=246954&r2=24
> 6955&view=diff 
> ==
> 
> --- 
> lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86
> _64.cpp (original)
> +++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux
> +++ _x86_64.cpp Mon Sep  7 02:40:16 2015
> @@ -422,6 +422,10 @@ NativeRegisterContextLinux_x86_64::Nativ
>
>  // Clear out the FPR state.
>  ::memset(&m_fpr, 0, sizeof(FPR));
> +
> +// Store byte offset of fctrl (i.e. first register of FPR)
> +const RegisterInfo *reg_info_fctrl = GetRegisterInfoByName("fctrl");
> +m_fctrl_offset_in_userarea = reg_info_fctrl->byte_offset;
>  }
>
>  // CONSIDER after local and llgs debugging are merged, register set 
> support can @@ -559,8 +563,16 @@ NativeRegisterContextLinux_x86_64::ReadR
>  }
>
>  // Get pointer to m_fpr.xstate.fxsave variable and set the data from it.
> -assert (reg_info->byte_offset < sizeof(m_fpr));
> -uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset;
> +
> +// Byte offsets of all registers are calculated wrt 'UserArea' structure.
> +// However, ReadFPR() reads fpu registers {using 
> ptrace(PTRACE_GETFPREGS,..)}
> +// and stores them in 'm_fpr' (of type FPR structure). To extract values 
> of fpu
> +// registers, m_fpr should be read at byte offsets calculated wrt to FPR 
> structure.
> +
> +// Since, FPR structure is also one of the member of UserArea structure.
> +// byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) - 
> byte_offset(fctrl wrt UserArea)
> +assert ( (reg_info->byte_offset - m_fctrl_offset_in_userarea) < 
> sizeof(m_fpr));
> +uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset - 
> + m_fctrl_offset_in_userarea;
>  switch (reg_info->byte_size)
>  {
>  case 2:
> @@ -620,8 +632,16 @@ NativeRegisterContextLinux_x86_64::Write
>  else
>  {
>  // Get pointer to m_fpr.xstate.fxsave variable and set the data 
> to it.
> -assert (reg_info->byte_offset < sizeof(m_fpr));
> -uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset;
> +
> +// Byte

Re: [Lldb-commits] [lldb] r246955 - Bug 24457 - X87 FPU Special Purpose Registers

2015-09-07 Thread Pavel Labath via lldb-commits
Hi,

this new test fails when the inferior is compiled with clang, as the
produced line tables are not what you expect. I have marked it as
XFAIL to get the bots green, but it would be great if we could write
it in a way that works on clang as well.

pl


On 7 September 2015 at 08:40, Abhishek Aggarwal via lldb-commits
 wrote:
> Author: abhishek
> Date: Mon Sep  7 02:40:16 2015
> New Revision: 246955
>
> URL: http://llvm.org/viewvc/llvm-project?rev=246955&view=rev
> Log:
> Bug 24457 - X87 FPU Special Purpose Registers
>
> Summary:
>   - For 'register read --all' command on x86_64-Linux Platform:
>
>   -- Provide correct values of X87 FPU Special Purpose Registers
>   -- Both 32-bit & 64-bit inferiors give correct values on this
>  Platform
>
>   - Added a Test Vector:
>   -- To verify the expected behaviour of the command
>
> Signed-off-by: Abhishek Aggarwal 
>
> Reviewers: ashok.thirumurthi, granata.enrico, tfiala, clayborg
>
> Differential Revision: http://reviews.llvm.org/D12592
>
> Added:
> lldb/trunk/test/functionalities/register/a.cpp   (with props)
> Modified:
> 
> lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp 
>   (contents, props changed)
> 
> lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
> lldb/trunk/test/functionalities/register/Makefile   (contents, props 
> changed)
> lldb/trunk/test/functionalities/register/TestRegisters.py   (contents, 
> props changed)
> lldb/trunk/test/functionalities/register/main.cpp   (contents, props 
> changed)
>
> Modified: 
> lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp?rev=246955&r1=246954&r2=246955&view=diff
> ==
> --- 
> lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp 
> (original)
> +++ 
> lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp 
> Mon Sep  7 02:40:16 2015
> @@ -422,6 +422,10 @@ NativeRegisterContextLinux_x86_64::Nativ
>
>  // Clear out the FPR state.
>  ::memset(&m_fpr, 0, sizeof(FPR));
> +
> +// Store byte offset of fctrl (i.e. first register of FPR)
> +const RegisterInfo *reg_info_fctrl = GetRegisterInfoByName("fctrl");
> +m_fctrl_offset_in_userarea = reg_info_fctrl->byte_offset;
>  }
>
>  // CONSIDER after local and llgs debugging are merged, register set support 
> can
> @@ -559,8 +563,16 @@ NativeRegisterContextLinux_x86_64::ReadR
>  }
>
>  // Get pointer to m_fpr.xstate.fxsave variable and set the data from it.
> -assert (reg_info->byte_offset < sizeof(m_fpr));
> -uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset;
> +
> +// Byte offsets of all registers are calculated wrt 'UserArea' structure.
> +// However, ReadFPR() reads fpu registers {using 
> ptrace(PTRACE_GETFPREGS,..)}
> +// and stores them in 'm_fpr' (of type FPR structure). To extract values 
> of fpu
> +// registers, m_fpr should be read at byte offsets calculated wrt to FPR 
> structure.
> +
> +// Since, FPR structure is also one of the member of UserArea structure.
> +// byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) - 
> byte_offset(fctrl wrt UserArea)
> +assert ( (reg_info->byte_offset - m_fctrl_offset_in_userarea) < 
> sizeof(m_fpr));
> +uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset - 
> m_fctrl_offset_in_userarea;
>  switch (reg_info->byte_size)
>  {
>  case 2:
> @@ -620,8 +632,16 @@ NativeRegisterContextLinux_x86_64::Write
>  else
>  {
>  // Get pointer to m_fpr.xstate.fxsave variable and set the data 
> to it.
> -assert (reg_info->byte_offset < sizeof(m_fpr));
> -uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset;
> +
> +// Byte offsets of all registers are calculated wrt 'UserArea' 
> structure.
> +// However, WriteFPR() takes m_fpr (of type FPR structure) and 
> writes only fpu
> +// registers using ptrace(PTRACE_SETFPREGS,..) API. Hence fpu 
> registers should
> +// be written in m_fpr at byte offsets calculated wrt FPR 
> structure.
> +
> +// Since, FPR structure is also one of the member of UserArea 
> structure.
> +// byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) - 
> byte_offset(fctrl wrt UserArea)
> +assert ( (reg_info->byte_offset - m_fctrl_offset_in_userarea) < 
> sizeof(m_fpr));
> +uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset - 
> m_fctrl_offset_in_userarea;
>  switch (reg_info->byte_size)
>  {
>  case 2:
>
> Propchange: 
> lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
> -

[Lldb-commits] [lldb] r246955 - Bug 24457 - X87 FPU Special Purpose Registers

2015-09-07 Thread Abhishek Aggarwal via lldb-commits
Author: abhishek
Date: Mon Sep  7 02:40:16 2015
New Revision: 246955

URL: http://llvm.org/viewvc/llvm-project?rev=246955&view=rev
Log:
Bug 24457 - X87 FPU Special Purpose Registers

Summary:
  - For 'register read --all' command on x86_64-Linux Platform:

  -- Provide correct values of X87 FPU Special Purpose Registers
  -- Both 32-bit & 64-bit inferiors give correct values on this
 Platform

  - Added a Test Vector:
  -- To verify the expected behaviour of the command

Signed-off-by: Abhishek Aggarwal 

Reviewers: ashok.thirumurthi, granata.enrico, tfiala, clayborg

Differential Revision: http://reviews.llvm.org/D12592

Added:
lldb/trunk/test/functionalities/register/a.cpp   (with props)
Modified:

lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp   
(contents, props changed)
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
lldb/trunk/test/functionalities/register/Makefile   (contents, props 
changed)
lldb/trunk/test/functionalities/register/TestRegisters.py   (contents, 
props changed)
lldb/trunk/test/functionalities/register/main.cpp   (contents, props 
changed)

Modified: 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp?rev=246955&r1=246954&r2=246955&view=diff
==
--- 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp 
(original)
+++ 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp 
Mon Sep  7 02:40:16 2015
@@ -422,6 +422,10 @@ NativeRegisterContextLinux_x86_64::Nativ
 
 // Clear out the FPR state.
 ::memset(&m_fpr, 0, sizeof(FPR));
+
+// Store byte offset of fctrl (i.e. first register of FPR)
+const RegisterInfo *reg_info_fctrl = GetRegisterInfoByName("fctrl");
+m_fctrl_offset_in_userarea = reg_info_fctrl->byte_offset;
 }
 
 // CONSIDER after local and llgs debugging are merged, register set support can
@@ -559,8 +563,16 @@ NativeRegisterContextLinux_x86_64::ReadR
 }
 
 // Get pointer to m_fpr.xstate.fxsave variable and set the data from it.
-assert (reg_info->byte_offset < sizeof(m_fpr));
-uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset;
+
+// Byte offsets of all registers are calculated wrt 'UserArea' structure.
+// However, ReadFPR() reads fpu registers {using 
ptrace(PTRACE_GETFPREGS,..)}
+// and stores them in 'm_fpr' (of type FPR structure). To extract values 
of fpu
+// registers, m_fpr should be read at byte offsets calculated wrt to FPR 
structure.
+
+// Since, FPR structure is also one of the member of UserArea structure.
+// byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) - 
byte_offset(fctrl wrt UserArea)
+assert ( (reg_info->byte_offset - m_fctrl_offset_in_userarea) < 
sizeof(m_fpr));
+uint8_t *src = (uint8_t *)&m_fpr + reg_info->byte_offset - 
m_fctrl_offset_in_userarea;
 switch (reg_info->byte_size)
 {
 case 2:
@@ -620,8 +632,16 @@ NativeRegisterContextLinux_x86_64::Write
 else
 {
 // Get pointer to m_fpr.xstate.fxsave variable and set the data to 
it.
-assert (reg_info->byte_offset < sizeof(m_fpr));
-uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset;
+
+// Byte offsets of all registers are calculated wrt 'UserArea' 
structure.
+// However, WriteFPR() takes m_fpr (of type FPR structure) and 
writes only fpu
+// registers using ptrace(PTRACE_SETFPREGS,..) API. Hence fpu 
registers should
+// be written in m_fpr at byte offsets calculated wrt FPR 
structure.
+
+// Since, FPR structure is also one of the member of UserArea 
structure.
+// byte_offset(fpu wrt FPR) = byte_offset(fpu wrt UserArea) - 
byte_offset(fctrl wrt UserArea)
+assert ( (reg_info->byte_offset - m_fctrl_offset_in_userarea) < 
sizeof(m_fpr));
+uint8_t *dst = (uint8_t *)&m_fpr + reg_info->byte_offset - 
m_fctrl_offset_in_userarea;
 switch (reg_info->byte_size)
 {
 case 2:

Propchange: 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.cpp
--
svn:executable = *

Modified: 
lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h
URL: 
http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h?rev=246955&r1=246954&r2=246955&view=diff
==
--- lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h 
(original)
+++ lldb/trunk/source/Plugins/Process/Linux/NativeRegisterContextLinux_x86_64.h 
Mon S