Commit | Line | Data |
---|---|---|
f49ff000 YQ |
1 | /* GNU/Linux/x86-64 specific target description, for the remote server |
2 | for GDB. | |
3 | Copyright (C) 2017 Free Software Foundation, Inc. | |
4 | ||
5 | This file is part of GDB. | |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 3 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
19 | ||
20 | #include "server.h" | |
21 | #include "tdesc.h" | |
22 | #include "linux-x86-tdesc.h" | |
5f035c07 YQ |
23 | #include "arch/i386.h" |
24 | #include "common/x86-xstate.h" | |
f49ff000 | 25 | |
f49ff000 YQ |
26 | static struct target_desc *i386_tdescs[X86_TDESC_LAST] = { }; |
27 | ||
f49ff000 YQ |
28 | #if defined __i386__ || !defined IN_PROCESS_AGENT |
29 | ||
30 | /* Return the target description according to XCR0. */ | |
31 | ||
32 | const struct target_desc * | |
33 | i386_linux_read_description (uint64_t xcr0) | |
34 | { | |
35 | struct target_desc **tdesc = NULL; | |
36 | ||
37 | if (xcr0 & X86_XSTATE_PKRU) | |
38 | tdesc = &i386_tdescs[X86_TDESC_AVX_MPX_AVX512_PKU]; | |
39 | else if (xcr0 & X86_XSTATE_AVX512) | |
40 | tdesc = &i386_tdescs[X86_TDESC_AVX_AVX512]; | |
41 | else if ((xcr0 & X86_XSTATE_AVX_MPX_MASK) == X86_XSTATE_AVX_MPX_MASK) | |
42 | tdesc = &i386_tdescs[X86_TDESC_AVX_MPX]; | |
43 | else if (xcr0 & X86_XSTATE_MPX) | |
44 | tdesc = &i386_tdescs[X86_TDESC_MPX]; | |
45 | else if (xcr0 & X86_XSTATE_AVX) | |
46 | tdesc = &i386_tdescs[X86_TDESC_AVX]; | |
47 | else if (xcr0 & X86_XSTATE_SSE) | |
48 | tdesc = &i386_tdescs[X86_TDESC_SSE]; | |
49 | else if (xcr0 & X86_XSTATE_X87) | |
50 | tdesc = &i386_tdescs[X86_TDESC_MMX]; | |
51 | ||
52 | if (tdesc == NULL) | |
53 | return NULL; | |
54 | ||
55 | if (*tdesc == NULL) | |
56 | { | |
5f035c07 | 57 | *tdesc = i386_create_target_description (xcr0); |
f49ff000 YQ |
58 | |
59 | init_target_desc (*tdesc); | |
60 | ||
61 | #ifndef IN_PROCESS_AGENT | |
62 | static const char *expedite_regs_i386[] = { "ebp", "esp", "eip", NULL }; | |
63 | (*tdesc)->expedite_regs = expedite_regs_i386; | |
f49ff000 YQ |
64 | #endif |
65 | } | |
66 | ||
67 | return *tdesc;; | |
68 | } | |
69 | #endif | |
70 | ||
71 | #ifndef IN_PROCESS_AGENT | |
72 | int | |
73 | i386_get_ipa_tdesc_idx (const struct target_desc *tdesc) | |
74 | { | |
75 | for (int i = 0; i < X86_TDESC_LAST; i++) | |
76 | { | |
77 | if (tdesc == i386_tdescs[i]) | |
78 | return i; | |
79 | } | |
80 | ||
81 | /* If none tdesc is found, return the one with minimum features. */ | |
82 | return X86_TDESC_MMX; | |
83 | } | |
84 | ||
85 | #endif |