diff options
Diffstat (limited to 'gdb/arch')
-rw-r--r-- | gdb/arch/amd64.c | 74 | ||||
-rw-r--r-- | gdb/arch/amd64.h | 22 | ||||
-rw-r--r-- | gdb/arch/i386.c | 68 | ||||
-rw-r--r-- | gdb/arch/i386.h | 21 | ||||
-rw-r--r-- | gdb/arch/tdesc.h | 92 |
5 files changed, 277 insertions, 0 deletions
diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c new file mode 100644 index 0000000..30c73e6 --- /dev/null +++ b/gdb/arch/amd64.c @@ -0,0 +1,74 @@ +/* Copyright (C) 2017 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "amd64.h" +#include "x86-xstate.h" +#include <stdlib.h> + +#include "../features/i386/64bit-avx.c" +#include "../features/i386/64bit-avx512.c" +#include "../features/i386/64bit-core.c" +#include "../features/i386/64bit-linux.c" +#include "../features/i386/64bit-mpx.c" +#include "../features/i386/64bit-pkeys.c" +#include "../features/i386/64bit-segments.c" +#include "../features/i386/64bit-sse.c" + +#include "../features/i386/x32-core.c" + +/* Create amd64 target descriptions according to XCR0. If IS_X32 is + true, create the x32 ones. If IS_LINUX is true, create target + descriptions for Linux. */ + +target_desc * +amd64_create_target_description (uint64_t xcr0, bool is_x32, bool is_linux) +{ + target_desc *tdesc = allocate_target_description (); + +#ifndef IN_PROCESS_AGENT + set_tdesc_architecture (tdesc, is_x32 ? "i386:x64-32" : "i386:x86-64"); + + if (is_linux) + set_tdesc_osabi (tdesc, "GNU/Linux"); +#endif + + long regnum = 0; + + if (is_x32) + regnum = create_feature_i386_x32_core (tdesc, regnum); + else + regnum = create_feature_i386_64bit_core (tdesc, regnum); + + regnum = create_feature_i386_64bit_sse (tdesc, regnum); + if (is_linux) + regnum = create_feature_i386_64bit_linux (tdesc, regnum); + regnum = create_feature_i386_64bit_segments (tdesc, regnum); + + if (xcr0 & X86_XSTATE_AVX) + regnum = create_feature_i386_64bit_avx (tdesc, regnum); + + if ((xcr0 & X86_XSTATE_MPX) && !is_x32) + regnum = create_feature_i386_64bit_mpx (tdesc, regnum); + + if (xcr0 & X86_XSTATE_AVX512) + regnum = create_feature_i386_64bit_avx512 (tdesc, regnum); + + if ((xcr0 & X86_XSTATE_PKRU) && !is_x32) + regnum = create_feature_i386_64bit_pkeys (tdesc, regnum); + + return tdesc; +} diff --git a/gdb/arch/amd64.h b/gdb/arch/amd64.h new file mode 100644 index 0000000..22c63d2 --- /dev/null +++ b/gdb/arch/amd64.h @@ -0,0 +1,22 @@ +/* Copyright (C) 2017 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "tdesc.h" +#include <stdint.h> + +target_desc *amd64_create_target_description (uint64_t xcr0, bool is_x32, + bool is_linux); diff --git a/gdb/arch/i386.c b/gdb/arch/i386.c new file mode 100644 index 0000000..7d71506 --- /dev/null +++ b/gdb/arch/i386.c @@ -0,0 +1,68 @@ +/* Copyright (C) 2017 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "i386.h" +#include "tdesc.h" +#include "x86-xstate.h" +#include <stdlib.h> + +#include "../features/i386/32bit-core.c" +#include "../features/i386/32bit-linux.c" +#include "../features/i386/32bit-sse.c" +#include "../features/i386/32bit-avx.c" +#include "../features/i386/32bit-avx512.c" +#include "../features/i386/32bit-mpx.c" +#include "../features/i386/32bit-pkeys.c" + +/* Create i386 target descriptions according to XCR0. */ + +target_desc * +i386_create_target_description (uint64_t xcr0, bool is_linux) +{ + target_desc *tdesc = allocate_target_description (); + +#ifndef IN_PROCESS_AGENT + set_tdesc_architecture (tdesc, "i386"); + if (is_linux) + set_tdesc_osabi (tdesc, "GNU/Linux"); +#endif + + long regnum = 0; + + if (xcr0 & X86_XSTATE_X87) + regnum = create_feature_i386_32bit_core (tdesc, regnum); + + if (xcr0 & X86_XSTATE_SSE) + regnum = create_feature_i386_32bit_sse (tdesc, regnum); + + if (is_linux) + regnum = create_feature_i386_32bit_linux (tdesc, regnum); + + if (xcr0 & X86_XSTATE_AVX) + regnum = create_feature_i386_32bit_avx (tdesc, regnum); + + if (xcr0 & X86_XSTATE_MPX) + regnum = create_feature_i386_32bit_mpx (tdesc, regnum); + + if (xcr0 & X86_XSTATE_AVX512) + regnum = create_feature_i386_32bit_avx512 (tdesc, regnum); + + if (xcr0 & X86_XSTATE_PKRU) + regnum = create_feature_i386_32bit_pkeys (tdesc, regnum); + + return tdesc; +} diff --git a/gdb/arch/i386.h b/gdb/arch/i386.h new file mode 100644 index 0000000..c44e24b --- /dev/null +++ b/gdb/arch/i386.h @@ -0,0 +1,21 @@ +/* Copyright (C) 2017 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "tdesc.h" +#include <stdint.h> + +target_desc *i386_create_target_description (uint64_t xcr0, bool is_linux); diff --git a/gdb/arch/tdesc.h b/gdb/arch/tdesc.h new file mode 100644 index 0000000..78bb0fb --- /dev/null +++ b/gdb/arch/tdesc.h @@ -0,0 +1,92 @@ +/* Copyright (C) 2006-2017 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#ifndef ARCH_TDESC_H +#define ARCH_TDESC_H 1 + +struct tdesc_feature; +struct tdesc_type; +struct tdesc_reg; +struct target_desc; + +/* Allocate a new target_desc. */ +target_desc *allocate_target_description (void); + +/* Set TARGET_DESC's architecture by NAME. */ +void set_tdesc_architecture (target_desc *target_desc, + const char *name); + +/* Set TARGET_DESC's osabi by NAME. */ +void set_tdesc_osabi (target_desc *target_desc, const char *name); + +/* Return the type associated with ID in the context of FEATURE, or + NULL if none. */ +struct tdesc_type *tdesc_named_type (const struct tdesc_feature *feature, + const char *id); + +/* Return the created feature named NAME in target description TDESC. */ +struct tdesc_feature *tdesc_create_feature (struct target_desc *tdesc, + const char *name, + const char *xml = nullptr); + + +/* Return the created vector tdesc_type named NAME in FEATURE. */ +struct tdesc_type *tdesc_create_vector (struct tdesc_feature *feature, + const char *name, + struct tdesc_type *field_type, + int count); + +/* Return the created struct tdesc_type named NAME in FEATURE. */ +struct tdesc_type *tdesc_create_struct (struct tdesc_feature *feature, + const char *name); + +/* Return the created union tdesc_type named NAME in FEATURE. */ +struct tdesc_type *tdesc_create_union (struct tdesc_feature *feature, + const char *name); + +/* Return the created flags tdesc_type named NAME in FEATURE. */ +struct tdesc_type *tdesc_create_flags (struct tdesc_feature *feature, + const char *name, + int size); + +/* Add a new field to TYPE. FIELD_NAME is its name, and FIELD_TYPE is + its type. */ +void tdesc_add_field (struct tdesc_type *type, const char *field_name, + struct tdesc_type *field_type); + +/* Set the total length of TYPE. Structs which contain bitfields may + omit the reserved bits, so the end of the last field may not + suffice. */ +void tdesc_set_struct_size (struct tdesc_type *type, int size); + +/* Add a new untyped bitfield to TYPE. + Untyped bitfields become either uint32 or uint64 depending on the size + of the underlying type. */ +void tdesc_add_bitfield (struct tdesc_type *type, const char *field_name, + int start, int end); + +/* A flag is just a typed(bool) single-bit bitfield. + This function is kept to minimize changes in generated files. */ +void tdesc_add_flag (struct tdesc_type *type, int start, + const char *flag_name); + +/* Create a register in feature FEATURE. */ +void tdesc_create_reg (struct tdesc_feature *feature, const char *name, + int regnum, int save_restore, const char *group, + int bitsize, const char *type); + +#endif /* ARCH_TDESC_H */ |