1 /* GNU/Linux/x86-64 specific target description, for the remote server
3 Copyright (C) 2017 Free Software Foundation, Inc.
5 This file is part of GDB.
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.
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.
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/>. */
22 #include "linux-x86-tdesc.h"
23 #include "arch/i386.h"
24 #include "common/x86-xstate.h"
26 static struct target_desc
*i386_tdescs
[X86_TDESC_LAST
] = { };
28 #if defined __i386__ || !defined IN_PROCESS_AGENT
30 /* Return the target description according to XCR0. */
32 const struct target_desc
*
33 i386_linux_read_description (uint64_t xcr0
)
35 struct target_desc
**tdesc
= NULL
;
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
];
57 *tdesc
= i386_create_target_description (xcr0
);
59 init_target_desc (*tdesc
);
61 #ifndef IN_PROCESS_AGENT
62 static const char *expedite_regs_i386
[] = { "ebp", "esp", "eip", NULL
};
63 (*tdesc
)->expedite_regs
= expedite_regs_i386
;
71 #ifndef IN_PROCESS_AGENT
73 i386_get_ipa_tdesc_idx (const struct target_desc
*tdesc
)
75 for (int i
= 0; i
< X86_TDESC_LAST
; i
++)
77 if (tdesc
== i386_tdescs
[i
])
81 /* If none tdesc is found, return the one with minimum features. */