[lldb-dev] [PATCH] 32-bit linux use hard-coded DR0 offset not offsetof against a structure

Todd Fiala tfiala at google.com
Tue Mar 4 14:06:55 PST 2014


This is now in as part of r202887.


On Tue, Mar 4, 2014 at 2:22 AM, Matthew Gardiner <mg11 at csr.com> wrote:

> Hi folks
>
> I'm posting this to dev not commits as it's slightly contentious, but when
> combined with an earlier posting of mine:
>
> [Lldb-commits] [PATCH] 32-bit linux Remove WriteRegOperation's explicit
> GetAsUInt32() call
>
> this proposal fixes the 32-bit linux debug experience.
>
> This patch proposes to calculate the offset of an i386 debug offset using a
> simple base + multiple sum, instead using offsetof against a structure.
>
> We all know that there are lots of ways to solve this problem. I'm posting
> this
> one as it is compact and fits with the existing "#define
> DR_OFFSET(reg_index)"
> pattern.
>
> Index: source/Plugins/Process/POSIX/RegisterContextLinux_i386.cpp
> ===================================================================
> --- source/Plugins/Process/POSIX/RegisterContextLinux_i386.cpp  (revision
> 202806)
> +++ source/Plugins/Process/POSIX/RegisterContextLinux_i386.cpp  (working
> copy)
> @@ -83,8 +83,9 @@
>  };
>
>  #define DR_SIZE sizeof(UserArea::u_debugreg[0])
> +#define DR_0_OFFSET 0xFC
>  #define DR_OFFSET(reg_index) \
> -    (LLVM_EXTENSION offsetof(UserArea, u_debugreg[reg_index]))
> +    (DR_0_OFFSET + (reg_index * 4))
>  #define FPR_SIZE(reg) sizeof(((FPR_i386*)NULL)->reg)
>
>  //----------------------------------------------------------
> -----------------
>
>
> Using the offsetof(struct, element) mantra can be problematic, if the
> underlying
> structure is changed, and has no benefits IMO if the structure is not also
> used
> as a structure.
>
> Could someone apply this or a similar patch?
>
> thanks
> Matt
>
>
>
>
> Member of the CSR plc group of companies. CSR plc registered in England
> and Wales, registered number 4187346, registered office Churchill House,
> Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
> More information can be found at www.csr.com. Keep up to date with CSR on
> our technical blog, www.csr.com/blog, CSR people blog, www.csr.com/people,
> YouTube, www.youtube.com/user/CSRplc, Facebook,
> www.facebook.com/pages/CSR/191038434253534, or follow us on Twitter at
> www.twitter.com/CSR_plc.
> New for 2014, you can now access the wide range of products powered by
> aptX at www.aptx.com.
>
> _______________________________________________
> lldb-dev mailing list
> lldb-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev
>
>


-- 
Todd Fiala | Software Engineer | tfiala at google.com | 650-943-3180
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20140304/95b6c7d3/attachment.html>


More information about the lldb-dev mailing list