GNU Binutils with patches for OS216
Revision | 2e83593c514fad6fd41bd29efb1c31284a536f3d (tree) |
---|---|
Zeit | 2017-07-10 22:42:51 |
Autor | Yao Qi <yao.qi@lina...> |
Commiter | Yao Qi |
Centralize amd64-linux target descriptions
This patch adds a new function amd64_linux_read_description, which
creates amd64-linux target descriptions according to its two
arguments, xcr0 and is_x32.
gdb:
2017-06-07 Yao Qi <yao.qi@linaro.org>
* amd64-linux-tdep.c (amd64_linux_read_description): New
function.
(amd64_linux_core_read_description): Call
amd64_linux_read_description.
(amd64_linux_init_abi): Likewise.
(amd64_x32_linux_init_abi): Likewise.
* amd64-linux-tdep.h (amd64_linux_read_description): Declare.
* x86-linux-nat.c (x86_linux_read_description): Call
amd64_linux_read_description.
@@ -1575,54 +1575,61 @@ amd64_linux_record_signal (struct gdbarch *gdbarch, | ||
1575 | 1575 | return 0; |
1576 | 1576 | } |
1577 | 1577 | |
1578 | -/* Get Linux/x86 target description from core dump. */ | |
1579 | - | |
1580 | -static const struct target_desc * | |
1581 | -amd64_linux_core_read_description (struct gdbarch *gdbarch, | |
1582 | - struct target_ops *target, | |
1583 | - bfd *abfd) | |
1578 | +const target_desc * | |
1579 | +amd64_linux_read_description (uint64_t xcr0_features_bit, bool is_x32) | |
1584 | 1580 | { |
1585 | - /* Linux/x86-64. */ | |
1586 | - uint64_t xcr0 = i386_linux_core_read_xcr0 (abfd); | |
1587 | - | |
1588 | - switch (xcr0 & X86_XSTATE_ALL_MASK) | |
1581 | + switch (xcr0_features_bit) | |
1589 | 1582 | { |
1590 | 1583 | case X86_XSTATE_AVX_MPX_AVX512_PKU_MASK: |
1591 | - if (gdbarch_ptr_bit (gdbarch) == 32) | |
1584 | + if (is_x32) | |
1592 | 1585 | /* No MPX, PKU on x32, fallback to AVX-AVX512. */ |
1593 | 1586 | return tdesc_x32_avx_avx512_linux; |
1594 | 1587 | else |
1595 | 1588 | return tdesc_amd64_avx_mpx_avx512_pku_linux; |
1596 | 1589 | case X86_XSTATE_AVX_AVX512_MASK: |
1597 | - if (gdbarch_ptr_bit (gdbarch) == 32) | |
1590 | + if (is_x32) | |
1598 | 1591 | return tdesc_x32_avx_avx512_linux; |
1599 | 1592 | else |
1600 | 1593 | return tdesc_amd64_avx_avx512_linux; |
1601 | 1594 | case X86_XSTATE_MPX_MASK: |
1602 | - if (gdbarch_ptr_bit (gdbarch) == 32) | |
1595 | + if (is_x32) | |
1603 | 1596 | /* No MPX on x32, fallback to AVX. */ |
1604 | 1597 | return tdesc_x32_avx_linux; |
1605 | 1598 | else |
1606 | 1599 | return tdesc_amd64_mpx_linux; |
1607 | 1600 | case X86_XSTATE_AVX_MPX_MASK: |
1608 | - if (gdbarch_ptr_bit (gdbarch) == 32) | |
1601 | + if (is_x32) | |
1609 | 1602 | /* No MPX on x32, fallback to AVX. */ |
1610 | 1603 | return tdesc_x32_avx_linux; |
1611 | 1604 | else |
1612 | 1605 | return tdesc_amd64_avx_mpx_linux; |
1613 | 1606 | case X86_XSTATE_AVX_MASK: |
1614 | - if (gdbarch_ptr_bit (gdbarch) == 32) | |
1607 | + if (is_x32) | |
1615 | 1608 | return tdesc_x32_avx_linux; |
1616 | 1609 | else |
1617 | 1610 | return tdesc_amd64_avx_linux; |
1618 | 1611 | default: |
1619 | - if (gdbarch_ptr_bit (gdbarch) == 32) | |
1612 | + if (is_x32) | |
1620 | 1613 | return tdesc_x32_linux; |
1621 | 1614 | else |
1622 | 1615 | return tdesc_amd64_linux; |
1623 | 1616 | } |
1624 | 1617 | } |
1625 | 1618 | |
1619 | +/* Get Linux/x86 target description from core dump. */ | |
1620 | + | |
1621 | +static const struct target_desc * | |
1622 | +amd64_linux_core_read_description (struct gdbarch *gdbarch, | |
1623 | + struct target_ops *target, | |
1624 | + bfd *abfd) | |
1625 | +{ | |
1626 | + /* Linux/x86-64. */ | |
1627 | + uint64_t xcr0 = i386_linux_core_read_xcr0 (abfd); | |
1628 | + | |
1629 | + return amd64_linux_read_description (xcr0 & X86_XSTATE_ALL_MASK, | |
1630 | + gdbarch_ptr_bit (gdbarch) == 32); | |
1631 | +} | |
1632 | + | |
1626 | 1633 | /* Similar to amd64_supply_fpregset, but use XSAVE extended state. */ |
1627 | 1634 | |
1628 | 1635 | static void |
@@ -1881,7 +1888,7 @@ amd64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | ||
1881 | 1888 | set_gdbarch_num_regs (gdbarch, AMD64_LINUX_NUM_REGS); |
1882 | 1889 | |
1883 | 1890 | if (! tdesc_has_registers (tdesc)) |
1884 | - tdesc = tdesc_amd64_linux; | |
1891 | + tdesc = amd64_linux_read_description (X86_XSTATE_SSE_MASK, false); | |
1885 | 1892 | tdep->tdesc = tdesc; |
1886 | 1893 | |
1887 | 1894 | feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux"); |
@@ -2098,7 +2105,7 @@ amd64_x32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | ||
2098 | 2105 | set_gdbarch_num_regs (gdbarch, AMD64_LINUX_NUM_REGS); |
2099 | 2106 | |
2100 | 2107 | if (! tdesc_has_registers (tdesc)) |
2101 | - tdesc = tdesc_x32_linux; | |
2108 | + tdesc = amd64_linux_read_description (X86_XSTATE_SSE_MASK, true); | |
2102 | 2109 | tdep->tdesc = tdesc; |
2103 | 2110 | |
2104 | 2111 | feature = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.linux"); |
@@ -43,6 +43,12 @@ extern struct target_desc *tdesc_x32_linux; | ||
43 | 43 | extern struct target_desc *tdesc_x32_avx_linux; |
44 | 44 | extern struct target_desc *tdesc_x32_avx_avx512_linux; |
45 | 45 | |
46 | +/* Return the right amd64-linux target descriptions according to | |
47 | + XCR0_FEATURES_BIT and IS_X32. */ | |
48 | + | |
49 | +const target_desc *amd64_linux_read_description (uint64_t xcr0_features_bit, | |
50 | + bool is_x32); | |
51 | + | |
46 | 52 | /* Enum that defines the syscall identifiers for amd64 linux. |
47 | 53 | Used for process record/replay, these will be translated into |
48 | 54 | a gdb-canonical set of syscall ids in linux-record.c. */ |
@@ -192,40 +192,7 @@ x86_linux_read_description (struct target_ops *ops) | ||
192 | 192 | if (is_64bit) |
193 | 193 | { |
194 | 194 | #ifdef __x86_64__ |
195 | - switch (xcr0_features_bits) | |
196 | - { | |
197 | - case X86_XSTATE_AVX_MPX_AVX512_PKU_MASK: | |
198 | - if (is_x32) | |
199 | - /* No MPX, PKU on x32, fall back to AVX-AVX512. */ | |
200 | - return tdesc_x32_avx_avx512_linux; | |
201 | - else | |
202 | - return tdesc_amd64_avx_mpx_avx512_pku_linux; | |
203 | - case X86_XSTATE_AVX_AVX512_MASK: | |
204 | - if (is_x32) | |
205 | - return tdesc_x32_avx_avx512_linux; | |
206 | - else | |
207 | - return tdesc_amd64_avx_avx512_linux; | |
208 | - case X86_XSTATE_MPX_MASK: | |
209 | - if (is_x32) | |
210 | - return tdesc_x32_avx_linux; /* No MPX on x32 using AVX. */ | |
211 | - else | |
212 | - return tdesc_amd64_mpx_linux; | |
213 | - case X86_XSTATE_AVX_MPX_MASK: | |
214 | - if (is_x32) | |
215 | - return tdesc_x32_avx_linux; /* No MPX on x32 using AVX. */ | |
216 | - else | |
217 | - return tdesc_amd64_avx_mpx_linux; | |
218 | - case X86_XSTATE_AVX_MASK: | |
219 | - if (is_x32) | |
220 | - return tdesc_x32_avx_linux; | |
221 | - else | |
222 | - return tdesc_amd64_avx_linux; | |
223 | - default: | |
224 | - if (is_x32) | |
225 | - return tdesc_x32_linux; | |
226 | - else | |
227 | - return tdesc_amd64_linux; | |
228 | - } | |
195 | + return amd64_linux_read_description (xcr0_features_bits, is_x32); | |
229 | 196 | #endif |
230 | 197 | } |
231 | 198 | else |