GNU Binutils with patches for OS216
Revisão | a1bf24956370142803e3204fb64f5cbd5c69c750 (tree) |
---|---|
Hora | 2012-03-06 22:19:13 |
Autor | Pedro Alves <palves@redh...> |
Commiter | Pedro Alves |
2012-03-06 Pedro Alves <palves@redhat.com>
PR gdb/13766
* i387-tdep.c (i387_supply_xsave): If we have an xsave buffer, and
the register state is clear, supply explicit zero, instead of
marking the register unavailable.
@@ -1,3 +1,11 @@ | ||
1 | +2012-03-06 Pedro Alves <palves@redhat.com> | |
2 | + | |
3 | + PR gdb/13766 | |
4 | + | |
5 | + * i387-tdep.c (i387_supply_xsave): If we have an xsave buffer, and | |
6 | + the register state is clear, supply explicit zero, instead of | |
7 | + marking the register unavailable. | |
8 | + | |
1 | 9 | 2011-10-20 Aleksandar Ristovski <aristovski@qnx.com> |
2 | 10 | |
3 | 11 | * cp-namespace.c (cp_scan_for_anonymous_namespaces): Changed function |
@@ -726,6 +726,7 @@ i387_supply_xsave (struct regcache *regcache, int regnum, | ||
726 | 726 | const gdb_byte *regs = xsave; |
727 | 727 | int i; |
728 | 728 | unsigned int clear_bv; |
729 | + static const gdb_byte zero[MAX_REGISTER_SIZE] = { 0 }; | |
729 | 730 | const gdb_byte *p; |
730 | 731 | enum |
731 | 732 | { |
@@ -765,6 +766,19 @@ i387_supply_xsave (struct regcache *regcache, int regnum, | ||
765 | 766 | else |
766 | 767 | clear_bv = I386_XSTATE_AVX_MASK; |
767 | 768 | |
769 | + /* With the delayed xsave mechanism, in between the program | |
770 | + starting, and the program accessing the vector registers for the | |
771 | + first time, the register's values are invalid. The kernel | |
772 | + initializes register states to zero when they are set the first | |
773 | + time in a program. This means that from the user-space programs' | |
774 | + perspective, it's the same as if the registers have always been | |
775 | + zero from the start of the program. Therefore, the debugger | |
776 | + should provide the same illusion to the user. | |
777 | + | |
778 | + Note however, the case when REGS is NULL is a different case. | |
779 | + That case means we do not have access to the x87 states, so we | |
780 | + should mark the registers as unavailable (by supplying NULL). */ | |
781 | + | |
768 | 782 | switch (regclass) |
769 | 783 | { |
770 | 784 | case none: |
@@ -772,26 +786,26 @@ i387_supply_xsave (struct regcache *regcache, int regnum, | ||
772 | 786 | |
773 | 787 | case avxh: |
774 | 788 | if ((clear_bv & I386_XSTATE_AVX)) |
775 | - p = NULL; | |
789 | + regcache_raw_supply (regcache, regnum, regs == NULL ? NULL : zero); | |
776 | 790 | else |
777 | - p = XSAVE_AVXH_ADDR (tdep, regs, regnum); | |
778 | - regcache_raw_supply (regcache, regnum, p); | |
791 | + regcache_raw_supply (regcache, regnum, | |
792 | + XSAVE_AVXH_ADDR (tdep, regs, regnum)); | |
779 | 793 | return; |
780 | 794 | |
781 | 795 | case sse: |
782 | 796 | if ((clear_bv & I386_XSTATE_SSE)) |
783 | - p = NULL; | |
797 | + regcache_raw_supply (regcache, regnum, regs == NULL ? NULL : zero); | |
784 | 798 | else |
785 | - p = FXSAVE_ADDR (tdep, regs, regnum); | |
786 | - regcache_raw_supply (regcache, regnum, p); | |
799 | + regcache_raw_supply (regcache, regnum, | |
800 | + FXSAVE_ADDR (tdep, regs, regnum)); | |
787 | 801 | return; |
788 | 802 | |
789 | 803 | case x87: |
790 | 804 | if ((clear_bv & I386_XSTATE_X87)) |
791 | - p = NULL; | |
805 | + regcache_raw_supply (regcache, regnum, regs == NULL ? NULL : zero); | |
792 | 806 | else |
793 | - p = FXSAVE_ADDR (tdep, regs, regnum); | |
794 | - regcache_raw_supply (regcache, regnum, p); | |
807 | + regcache_raw_supply (regcache, regnum, | |
808 | + FXSAVE_ADDR (tdep, regs, regnum)); | |
795 | 809 | return; |
796 | 810 | |
797 | 811 | case all: |
@@ -799,16 +813,19 @@ i387_supply_xsave (struct regcache *regcache, int regnum, | ||
799 | 813 | if ((tdep->xcr0 & I386_XSTATE_AVX)) |
800 | 814 | { |
801 | 815 | if ((clear_bv & I386_XSTATE_AVX)) |
802 | - p = NULL; | |
816 | + { | |
817 | + for (i = I387_YMM0H_REGNUM (tdep); | |
818 | + i < I387_YMMENDH_REGNUM (tdep); | |
819 | + i++) | |
820 | + regcache_raw_supply (regcache, i, regs == NULL ? NULL : zero); | |
821 | + } | |
803 | 822 | else |
804 | - p = regs; | |
805 | - | |
806 | - for (i = I387_YMM0H_REGNUM (tdep); | |
807 | - i < I387_YMMENDH_REGNUM (tdep); i++) | |
808 | 823 | { |
809 | - if (p != NULL) | |
810 | - p = XSAVE_AVXH_ADDR (tdep, regs, i); | |
811 | - regcache_raw_supply (regcache, i, p); | |
824 | + for (i = I387_YMM0H_REGNUM (tdep); | |
825 | + i < I387_YMMENDH_REGNUM (tdep); | |
826 | + i++) | |
827 | + regcache_raw_supply (regcache, i, | |
828 | + XSAVE_AVXH_ADDR (tdep, regs, i)); | |
812 | 829 | } |
813 | 830 | } |
814 | 831 |
@@ -816,16 +833,18 @@ i387_supply_xsave (struct regcache *regcache, int regnum, | ||
816 | 833 | if ((tdep->xcr0 & I386_XSTATE_SSE)) |
817 | 834 | { |
818 | 835 | if ((clear_bv & I386_XSTATE_SSE)) |
819 | - p = NULL; | |
836 | + { | |
837 | + for (i = I387_XMM0_REGNUM (tdep); | |
838 | + i < I387_MXCSR_REGNUM (tdep); | |
839 | + i++) | |
840 | + regcache_raw_supply (regcache, i, regs == NULL ? NULL : zero); | |
841 | + } | |
820 | 842 | else |
821 | - p = regs; | |
822 | - | |
823 | - for (i = I387_XMM0_REGNUM (tdep); | |
824 | - i < I387_MXCSR_REGNUM (tdep); i++) | |
825 | 843 | { |
826 | - if (p != NULL) | |
827 | - p = FXSAVE_ADDR (tdep, regs, i); | |
828 | - regcache_raw_supply (regcache, i, p); | |
844 | + for (i = I387_XMM0_REGNUM (tdep); | |
845 | + i < I387_MXCSR_REGNUM (tdep); i++) | |
846 | + regcache_raw_supply (regcache, i, | |
847 | + FXSAVE_ADDR (tdep, regs, i)); | |
829 | 848 | } |
830 | 849 | } |
831 | 850 |
@@ -833,16 +852,18 @@ i387_supply_xsave (struct regcache *regcache, int regnum, | ||
833 | 852 | if ((tdep->xcr0 & I386_XSTATE_X87)) |
834 | 853 | { |
835 | 854 | if ((clear_bv & I386_XSTATE_X87)) |
836 | - p = NULL; | |
855 | + { | |
856 | + for (i = I387_ST0_REGNUM (tdep); | |
857 | + i < I387_FCTRL_REGNUM (tdep); | |
858 | + i++) | |
859 | + regcache_raw_supply (regcache, i, regs == NULL ? NULL : zero); | |
860 | + } | |
837 | 861 | else |
838 | - p = regs; | |
839 | - | |
840 | - for (i = I387_ST0_REGNUM (tdep); | |
841 | - i < I387_FCTRL_REGNUM (tdep); i++) | |
842 | 862 | { |
843 | - if (p != NULL) | |
844 | - p = FXSAVE_ADDR (tdep, regs, i); | |
845 | - regcache_raw_supply (regcache, i, p); | |
863 | + for (i = I387_ST0_REGNUM (tdep); | |
864 | + i < I387_FCTRL_REGNUM (tdep); | |
865 | + i++) | |
866 | + regcache_raw_supply (regcache, i, FXSAVE_ADDR (tdep, regs, i)); | |
846 | 867 | } |
847 | 868 | } |
848 | 869 | break; |