[Lldb-commits] [lldb] r342029 - Reduce alignment on struct XSAVE, fixing a gcc warning

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 12 07:37:11 PDT 2018


Don't we get a blob of register bytes back from ptrace when reading registers? The struct we use must match this byte for byte. This seems like this change could affect the ability to get correct register values?

> On Sep 12, 2018, at 1:50 AM, Pavel Labath via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> 
> Author: labath
> Date: Wed Sep 12 01:50:08 2018
> New Revision: 342029
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=342029&view=rev
> Log:
> Reduce alignment on struct XSAVE, fixing a gcc warning
> 
> The warning is about heap-allocating a struct with bigger alignment
> requirements than the standard heap allocator provides.
> 
> AFAICT, all uses of the XSAVE struct are already heap-allocated, so this
> high alignment does not actually have any effect and removing it should
> be NFC.
> 
> I have also done some digging in the commit history. This alignment
> requirement was since the XSAVE struct was introduced in r180572 when
> adding AVX register support for linux. It does not mention the alignment
> specifically, so I am guessing this was just put there because the
> corresponging XSAVE cpu instruction requires its buffer to be 64-byte
> aligned. However, LLDB will not be normally reading this struct via the
> XSAVE instruction directly. Instead we will ask the kernel to copy the
> buffer saved when suspeding the inferior. This should not require such
> strict alignment (in fact, linux kernel will happily do this for any
> alignment).
> 
> Modified:
>    lldb/trunk/source/Plugins/Process/Utility/RegisterContext_x86.h
> 
> Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContext_x86.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContext_x86.h?rev=342029&r1=342028&r2=342029&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Process/Utility/RegisterContext_x86.h (original)
> +++ lldb/trunk/source/Plugins/Process/Utility/RegisterContext_x86.h Wed Sep 12 01:50:08 2018
> @@ -341,7 +341,7 @@ LLVM_PACKED_END
> 
> // x86 extensions to FXSAVE (i.e. for AVX and MPX processors)
> LLVM_PACKED_START
> -struct LLVM_ALIGNAS(64) XSAVE {
> +struct LLVM_ALIGNAS(16) XSAVE {
>   FXSAVE i387;      // floating point registers typical in i387_fxsave_struct
>   XSAVE_HDR header; // The xsave_hdr_struct can be used to determine if the
>                     // following extensions are usable
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits



More information about the lldb-commits mailing list