+2017-09-05 Yao Qi <yao.qi@linaro.org>
+
+ * arch/tdesc.h: New file.
+ * regformats/regdat.sh: Generate code using tdesc_create_reg.
+ * target-descriptions.c: Update comments.
+ * target-descriptions.h: Include "arch/tdesc.h". Remove the
+ declarations.
+ * features/i386/32bit-avx.c: Re-generated.
+ * features/i386/32bit-avx512.c: Re-generated.
+ * features/i386/32bit-core.c: Re-generated.
+ * features/i386/32bit-linux.c: Re-generated.
+ * features/i386/32bit-mpx.c: Re-generated.
+ * features/i386/32bit-pkeys.c: Re-generated.
+ * features/i386/32bit-sse.c: Re-generated.
+
2017-09-05 Yao Qi <yao.qi@linaro.org>
* regformats/regdat.sh: Update generated code.
--- /dev/null
+/* 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;
+
+/* 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);
+
+/* 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 */
/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
Original: 32bit-avx.xml */
-#include "target-descriptions.h"
+#include "arch/tdesc.h"
static int
create_feature_i386_32bit_avx (struct target_desc *result, long regnum)
/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
Original: 32bit-avx512.xml */
-#include "target-descriptions.h"
+#include "arch/tdesc.h"
static int
create_feature_i386_32bit_avx512 (struct target_desc *result, long regnum)
/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
Original: 32bit-core.xml */
-#include "target-descriptions.h"
+#include "arch/tdesc.h"
static int
create_feature_i386_32bit_core (struct target_desc *result, long regnum)
/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
Original: 32bit-linux.xml */
-#include "target-descriptions.h"
+#include "arch/tdesc.h"
static int
create_feature_i386_32bit_linux (struct target_desc *result, long regnum)
/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
Original: 32bit-mpx.xml */
-#include "target-descriptions.h"
+#include "arch/tdesc.h"
static int
create_feature_i386_32bit_mpx (struct target_desc *result, long regnum)
/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
Original: 32bit-pkeys.xml */
-#include "target-descriptions.h"
+#include "arch/tdesc.h"
static int
create_feature_i386_32bit_pkeys (struct target_desc *result, long regnum)
/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
Original: 32bit-sse.xml */
-#include "target-descriptions.h"
+#include "arch/tdesc.h"
static int
create_feature_i386_32bit_sse (struct target_desc *result, long regnum)
+2017-09-05 Yao Qi <yao.qi@linaro.org>
+
+ * configure.srv (srv_tgtobj): Append linux-x86-tdesc.o.
+ (ipa_obj): Likewise.
+ * linux-i386-ipa.c: Include common/x86-xstate.h
+ (get_ipa_tdesc): Call i386_linux_read_description.
+ (initialize_low_tracepoint): Don't call init_registers_XXX
+ functions, call initialize_low_tdesc instead.
+ * linux-x86-low.c (x86_linux_read_description): Call
+ i386_linux_read_description.
+ (initialize_low_arch): Don't call init_registers_i386_XXX
+ functions, call initialize_low_tdesc.
+ * linux-x86-tdesc.c: New file.
+ * linux-x86-tdesc.h (x86_linux_tdesc): New X86_TDESC_LAST.
+ (i386_get_ipa_tdesc_idx): Declare.
+ (i386_get_ipa_tdesc): Declare.
+ (initialize_low_tdesc): Declare.
+
2017-09-05 Yao Qi <yao.qi@linaro.org>
* linux-x86-low.c (x86_get_ipa_tdesc_idx): Use X86_TDESC_MMX
srv_tgtobj="amd64-linux-siginfo.o"
fi
srv_tgtobj="${srv_tgtobj} $srv_linux_obj linux-x86-low.o x86-low.o x86-dregs.o i387-fp.o"
+ srv_tgtobj="${srv_tgtobj} linux-x86-tdesc.o"
srv_tgtobj="${srv_tgtobj} linux-btrace.o x86-linux.o"
srv_tgtobj="${srv_tgtobj} x86-linux-dregs.o"
srv_linux_usrregs=yes
srv_linux_regsets=yes
srv_linux_thread_db=yes
srv_linux_btrace=yes
- ipa_obj="${ipa_i386_linux_regobj} linux-i386-ipa.o"
+ ipa_obj="${ipa_i386_linux_regobj} linux-i386-ipa.o linux-x86-tdesc-ipa.o"
;;
i[34567]86-*-lynxos*) srv_regobj="i386.o"
srv_tgtobj="lynx-low.o lynx-i386-low.o fork-child.o fork-inferior.o"
;;
x86_64-*-linux*) srv_regobj="$srv_amd64_linux_regobj $srv_i386_linux_regobj"
srv_tgtobj="$srv_linux_obj linux-x86-low.o x86-low.o x86-dregs.o i387-fp.o"
+ srv_tgtobj="${srv_tgtobj} linux-x86-tdesc.o"
srv_tgtobj="${srv_tgtobj} linux-btrace.o x86-linux.o"
srv_tgtobj="${srv_tgtobj} x86-linux-dregs.o"
srv_tgtobj="${srv_tgtobj} amd64-linux-siginfo.o"
else
ipa_obj="${ipa_amd64_linux_regobj}"
fi
- ipa_obj="${ipa_obj} linux-amd64-ipa.o"
+ ipa_obj="${ipa_obj} linux-amd64-ipa.o linux-x86-tdesc-ipa.o"
;;
x86_64-*-mingw*) srv_regobj="$srv_amd64_regobj"
srv_tgtobj="x86-low.o x86-dregs.o i387-fp.o win32-low.o win32-i386-low.o"
#include <sys/mman.h>
#include "tracepoint.h"
#include "linux-x86-tdesc.h"
+#include "common/x86-xstate.h"
/* GDB register numbers. */
const struct target_desc *
get_ipa_tdesc (int idx)
{
- switch (idx)
+ if (idx >= X86_TDESC_LAST)
{
- case X86_TDESC_MMX:
- return tdesc_i386_mmx_linux;
- case X86_TDESC_SSE:
- return tdesc_i386_linux;
- case X86_TDESC_AVX:
- return tdesc_i386_avx_linux;
- case X86_TDESC_MPX:
- return tdesc_i386_mpx_linux;
- case X86_TDESC_AVX_MPX:
- return tdesc_i386_avx_mpx_linux;
- case X86_TDESC_AVX_AVX512:
- return tdesc_i386_avx_avx512_linux;
- case X86_TDESC_AVX_MPX_AVX512_PKU:
- return tdesc_i386_avx_mpx_avx512_pku_linux;
- default:
internal_error (__FILE__, __LINE__,
"unknown ipa tdesc index: %d", idx);
- return tdesc_i386_linux;
}
+
+ /* Map the tdesc index to xcr0 mask. */
+ uint64_t idx2mask[X86_TDESC_LAST] = {
+ X86_XSTATE_X87_MASK,
+ X86_XSTATE_SSE_MASK,
+ X86_XSTATE_AVX_MASK,
+ X86_XSTATE_MPX_MASK,
+ X86_XSTATE_AVX_MPX_MASK,
+ X86_XSTATE_AVX_AVX512_MASK,
+ X86_XSTATE_AVX_MPX_AVX512_PKU_MASK,
+ };
+
+ return i386_linux_read_description (idx2mask[idx]);
}
/* Allocate buffer for the jump pads. On i386, we can reach an arbitrary
void
initialize_low_tracepoint (void)
{
- init_registers_i386_mmx_linux ();
- init_registers_i386_linux ();
- init_registers_i386_avx_linux ();
- init_registers_i386_mpx_linux ();
- init_registers_i386_avx_avx512_linux ();
- init_registers_i386_avx_mpx_avx512_pku_linux ();
+ initialize_low_tdesc ();
initialize_fast_tracepoint_trampoline_buffer ();
}
{
have_ptrace_getfpxregs = 0;
have_ptrace_getregset = 0;
- return tdesc_i386_mmx_linux;
+ return i386_linux_read_description (X86_XSTATE_X87);
}
else
have_ptrace_getfpxregs = 1;
}
else
{
- if (xcr0_features)
- {
- switch (xcr0 & X86_XSTATE_ALL_MASK)
- {
- case X86_XSTATE_AVX_MPX_AVX512_PKU_MASK:
- return tdesc_i386_avx_mpx_avx512_pku_linux;
-
- case (X86_XSTATE_AVX_AVX512_MASK):
- return tdesc_i386_avx_avx512_linux;
+ const target_desc *tdesc = NULL;
- case (X86_XSTATE_MPX_MASK):
- return tdesc_i386_mpx_linux;
-
- case (X86_XSTATE_AVX_MPX_MASK):
- return tdesc_i386_avx_mpx_linux;
+ if (xcr0_features)
+ tdesc = i386_linux_read_description (xcr0 & X86_XSTATE_ALL_MASK);
- case (X86_XSTATE_AVX_MASK):
- return tdesc_i386_avx_linux;
+ if (tdesc == NULL)
+ tdesc = i386_linux_read_description (X86_XSTATE_SSE);
- default:
- return tdesc_i386_linux;
- }
- }
- else
- return tdesc_i386_linux;
+ return tdesc;
}
gdb_assert_not_reached ("failed to return tdesc");
return X86_TDESC_AVX_AVX512;
#endif
- if (tdesc == tdesc_i386_mmx_linux)
- return X86_TDESC_MMX;
- if (tdesc == tdesc_i386_linux || tdesc == tdesc_i386_linux_no_xml)
+ if (tdesc == tdesc_i386_linux_no_xml)
return X86_TDESC_SSE;
- if (tdesc == tdesc_i386_avx_linux)
- return X86_TDESC_AVX;
- if (tdesc == tdesc_i386_mpx_linux)
- return X86_TDESC_MPX;
- if (tdesc == tdesc_i386_avx_mpx_linux)
- return X86_TDESC_AVX_MPX;
- if (tdesc == tdesc_i386_avx_mpx_avx512_pku_linux)
- return X86_TDESC_AVX_MPX_AVX512_PKU;
- if (tdesc == tdesc_i386_avx_avx512_linux)
- return X86_TDESC_AVX_AVX512;
- /* If none tdesc is found, return the one with minimum features. */
- return X86_TDESC_MMX;
+ return i386_get_ipa_tdesc_idx (tdesc);
}
/* This is initialized assuming an amd64 target.
copy_target_description (tdesc_amd64_linux_no_xml, tdesc_amd64_linux);
tdesc_amd64_linux_no_xml->xmltarget = xmltarget_amd64_linux_no_xml;
#endif
- init_registers_i386_linux ();
- init_registers_i386_mmx_linux ();
- init_registers_i386_avx_linux ();
- init_registers_i386_mpx_linux ();
- init_registers_i386_avx_mpx_linux ();
- init_registers_i386_avx_avx512_linux ();
- init_registers_i386_avx_mpx_avx512_pku_linux ();
+
+ initialize_low_tdesc ();
tdesc_i386_linux_no_xml = XNEW (struct target_desc);
- copy_target_description (tdesc_i386_linux_no_xml, tdesc_i386_linux);
+ copy_target_description (tdesc_i386_linux_no_xml,
+ i386_linux_read_description (X86_XSTATE_SSE_MASK));
tdesc_i386_linux_no_xml->xmltarget = xmltarget_i386_linux_no_xml;
initialize_regsets_info (&x86_regsets_info);
--- /dev/null
+/* GNU/Linux/x86-64 specific target description, for the remote server
+ for GDB.
+ 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 "server.h"
+#include "tdesc.h"
+#include "linux-x86-tdesc.h"
+#include "x86-xstate.h"
+#include <inttypes.h>
+
+#if defined __i386__ || !defined IN_PROCESS_AGENT
+#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"
+
+/* Defined in auto-generated file i386-linux.c. */
+void init_registers_i386_linux (void);
+extern const struct target_desc *tdesc_i386_linux;
+
+/* Defined in auto-generated file i386-mmx-linux.c. */
+void init_registers_i386_mmx_linux (void);
+extern const struct target_desc *tdesc_i386_mmx_linux;
+
+/* Defined in auto-generated file i386-avx-linux.c. */
+void init_registers_i386_avx_linux (void);
+extern const struct target_desc *tdesc_i386_avx_linux;
+
+/* Defined in auto-generated file i386-avx-mpx-linux.c. */
+void init_registers_i386_avx_mpx_linux (void);
+extern const struct target_desc *tdesc_i386_avx_mpx_linux;
+
+/* Defined in auto-generated file i386-avx-avx512-linux.c. */
+void init_registers_i386_avx_avx512_linux (void);
+extern const struct target_desc *tdesc_i386_avx_avx512_linux;
+
+/* Defined in auto-generated file i386-avx-mpx-avx512-linux.c. */
+void init_registers_i386_avx_mpx_avx512_pku_linux (void);
+extern const struct target_desc *tdesc_i386_avx_mpx_avx512_pku_linux;
+
+/* Defined in auto-generated file i386-mpx-linux.c. */
+void init_registers_i386_mpx_linux (void);
+extern const struct target_desc *tdesc_i386_mpx_linux;
+#endif
+
+static struct target_desc *i386_tdescs[X86_TDESC_LAST] = { };
+
+void
+initialize_low_tdesc ()
+{
+#if defined __i386__ || !defined IN_PROCESS_AGENT
+ init_registers_i386_linux ();
+ init_registers_i386_mmx_linux ();
+ init_registers_i386_avx_linux ();
+ init_registers_i386_mpx_linux ();
+ init_registers_i386_avx_mpx_linux ();
+ init_registers_i386_avx_avx512_linux ();
+ init_registers_i386_avx_mpx_avx512_pku_linux ();
+#endif
+}
+
+#if defined __i386__ || !defined IN_PROCESS_AGENT
+
+/* Return the target description according to XCR0. */
+
+const struct target_desc *
+i386_linux_read_description (uint64_t xcr0)
+{
+ struct target_desc **tdesc = NULL;
+
+ if (xcr0 & X86_XSTATE_PKRU)
+ tdesc = &i386_tdescs[X86_TDESC_AVX_MPX_AVX512_PKU];
+ else if (xcr0 & X86_XSTATE_AVX512)
+ tdesc = &i386_tdescs[X86_TDESC_AVX_AVX512];
+ else if ((xcr0 & X86_XSTATE_AVX_MPX_MASK) == X86_XSTATE_AVX_MPX_MASK)
+ tdesc = &i386_tdescs[X86_TDESC_AVX_MPX];
+ else if (xcr0 & X86_XSTATE_MPX)
+ tdesc = &i386_tdescs[X86_TDESC_MPX];
+ else if (xcr0 & X86_XSTATE_AVX)
+ tdesc = &i386_tdescs[X86_TDESC_AVX];
+ else if (xcr0 & X86_XSTATE_SSE)
+ tdesc = &i386_tdescs[X86_TDESC_SSE];
+ else if (xcr0 & X86_XSTATE_X87)
+ tdesc = &i386_tdescs[X86_TDESC_MMX];
+
+ if (tdesc == NULL)
+ return NULL;
+
+ if (*tdesc == NULL)
+ {
+ *tdesc = new target_desc ();
+
+ 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);
+
+ 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);
+
+ init_target_desc (*tdesc);
+
+#ifndef IN_PROCESS_AGENT
+ static const char *expedite_regs_i386[] = { "ebp", "esp", "eip", NULL };
+ (*tdesc)->expedite_regs = expedite_regs_i386;
+
+ if (xcr0 & X86_XSTATE_PKRU)
+ (*tdesc)->xmltarget = "i386-avx-mpx-avx512-pku-linux.xml";
+ else if (xcr0 & X86_XSTATE_AVX512)
+ (*tdesc)->xmltarget = "i386-avx-avx512-linux.xml";
+ else if ((xcr0 & X86_XSTATE_AVX_MPX_MASK) == X86_XSTATE_AVX_MPX_MASK)
+ (*tdesc)->xmltarget = "i386-avx-mpx-linux.xml";
+ else if (xcr0 & X86_XSTATE_MPX)
+ (*tdesc)->xmltarget = "i386-mpx-linux.xml";
+ else if (xcr0 & X86_XSTATE_AVX)
+ (*tdesc)->xmltarget = "i386-avx-linux.xml";
+ else if (xcr0 & X86_XSTATE_SSE)
+ (*tdesc)->xmltarget = "i386-linux.xml";
+ else if (xcr0 & X86_XSTATE_X87)
+ (*tdesc)->xmltarget = "i386-mmx-linux.xml";
+ else
+ internal_error (__FILE__, __LINE__,
+ "unknown xcr0: %" PRIu64, xcr0);
+#endif
+ }
+
+ return *tdesc;;
+}
+#endif
+
+#ifndef IN_PROCESS_AGENT
+int
+i386_get_ipa_tdesc_idx (const struct target_desc *tdesc)
+{
+ for (int i = 0; i < X86_TDESC_LAST; i++)
+ {
+ if (tdesc == i386_tdescs[i])
+ return i;
+ }
+
+ /* If none tdesc is found, return the one with minimum features. */
+ return X86_TDESC_MMX;
+}
+
+#endif
X86_TDESC_AVX_MPX = 4,
X86_TDESC_AVX_AVX512 = 5,
X86_TDESC_AVX_MPX_AVX512_PKU = 6,
+ X86_TDESC_LAST = 7,
};
#ifdef __x86_64__
#endif
#if defined __i386__ || !defined IN_PROCESS_AGENT
-/* Defined in auto-generated file i386-linux.c. */
-void init_registers_i386_linux (void);
-extern const struct target_desc *tdesc_i386_linux;
-
-/* Defined in auto-generated file i386-mmx-linux.c. */
-void init_registers_i386_mmx_linux (void);
-extern const struct target_desc *tdesc_i386_mmx_linux;
-
-/* Defined in auto-generated file i386-avx-linux.c. */
-void init_registers_i386_avx_linux (void);
-extern const struct target_desc *tdesc_i386_avx_linux;
-
-/* Defined in auto-generated file i386-avx-mpx-linux.c. */
-void init_registers_i386_avx_mpx_linux (void);
-extern const struct target_desc *tdesc_i386_avx_mpx_linux;
-
-/* Defined in auto-generated file i386-avx-avx512-linux.c. */
-void init_registers_i386_avx_avx512_linux (void);
-extern const struct target_desc *tdesc_i386_avx_avx512_linux;
+int i386_get_ipa_tdesc_idx (const struct target_desc *tdesc);
+#endif
-/* Defined in auto-generated file i386-avx-mpx-avx512-linux.c. */
-void init_registers_i386_avx_mpx_avx512_pku_linux (void);
-extern const struct target_desc *tdesc_i386_avx_mpx_avx512_pku_linux;
+const struct target_desc *i386_linux_read_description (uint64_t xcr0);
-/* Defined in auto-generated file i386-mpx-linux.c. */
-void init_registers_i386_mpx_linux (void);
-extern const struct target_desc *tdesc_i386_mpx_linux;
-#endif
+void initialize_low_tdesc ();
#ifndef IN_PROCESS_AGENT
-static const struct target_desc default_description = { NULL, 0, NULL, NULL };
+static const struct target_desc default_description {};
void
copy_target_description (struct target_desc *dest,
return current_process ()->tdesc;
}
-
#endif
+
+struct tdesc_type
+{};
+
+/* See arch/tdesc.h. */
+
+struct tdesc_feature *
+tdesc_create_feature (struct target_desc *tdesc, const char *name)
+{
+ return tdesc;
+}
+
+/* See arch/tdesc.h. */
+
+struct tdesc_type *
+tdesc_create_flags (struct tdesc_feature *feature, const char *name,
+ int size)
+{
+ return NULL;
+}
+
+/* See arch/tdesc.h. */
+
+void
+tdesc_add_flag (struct tdesc_type *type, int start,
+ const char *flag_name)
+{}
+
+/* See arch/tdesc.h. */
+
+struct tdesc_type *
+tdesc_named_type (const struct tdesc_feature *feature, const char *id)
+{
+ return NULL;
+}
+
+/* See arch/tdesc.h. */
+
+struct tdesc_type *
+tdesc_create_union (struct tdesc_feature *feature, const char *id)
+{
+ return NULL;
+}
+
+/* See arch/tdesc.h. */
+
+struct tdesc_type *
+tdesc_create_struct (struct tdesc_feature *feature, const char *id)
+{
+ return NULL;
+}
+
+/* See arch/tdesc.h. */
+
+void
+tdesc_create_reg (struct tdesc_feature *feature, const char *name,
+ int regnum, int save_restore, const char *group,
+ int bitsize, const char *type)
+{
+ struct target_desc *tdesc = (struct target_desc *) feature;
+
+ while (VEC_length (tdesc_reg_p, tdesc->reg_defs) < regnum)
+ {
+ struct reg *reg = XCNEW (struct reg);
+
+ reg->name = "";
+ reg->size = 0;
+ VEC_safe_push (tdesc_reg_p, tdesc->reg_defs, reg);
+ }
+
+ gdb_assert (regnum == 0
+ || regnum == VEC_length (tdesc_reg_p, tdesc->reg_defs));
+
+ struct reg *reg = XCNEW (struct reg);
+
+ reg->name = name;
+ reg->size = bitsize;
+ VEC_safe_push (tdesc_reg_p, tdesc->reg_defs, reg);
+}
+
+/* See arch/tdesc.h. */
+
+struct tdesc_type *
+tdesc_create_vector (struct tdesc_feature *feature, const char *name,
+ struct tdesc_type *field_type, int count)
+{
+ return NULL;
+}
+
+void
+tdesc_add_bitfield (struct tdesc_type *type, const char *field_name,
+ int start, int end)
+{}
+
+/* See arch/tdesc.h. */
+
+void
+tdesc_add_field (struct tdesc_type *type, const char *field_name,
+ struct tdesc_type *field_type)
+{}
+
+/* See arch/tdesc.h. */
+
+void
+tdesc_set_struct_size (struct tdesc_type *type, int size)
+{
+}
#ifndef TDESC_H
#define TDESC_H
+#include "arch/tdesc.h"
+
struct reg;
typedef struct reg *tdesc_reg_p;
DEF_VEC_P(tdesc_reg_p);
-/* A target description. */
+struct tdesc_feature
+{};
+
+/* A target description. Inherit from tdesc_feature so that target_desc
+ can be used as tdesc_feature. */
-struct target_desc
+struct target_desc : tdesc_feature
{
/* A vector of elements of register definitions that
describe the inferior's register set. */
#ifndef IN_PROCESS_AGENT
/* An array of register names. These are the "expedite" registers:
registers whose values are sent along with stop replies. */
- const char **expedite_regs;
+ const char **expedite_regs = NULL;
/* Defines what to return when looking for the "target.xml" file in
response to qXfer:features:read. Its contents can either be
verbatim XML code (prefixed with a '@') or else the name of the
actual XML file to be used in place of "target.xml". */
- const char *xmltarget;
+ const char *xmltarget = NULL;
+
+public:
+ target_desc ()
+ : reg_defs (NULL), registers_size (0)
+ {}
+
+ ~target_desc ()
+ {
+ int i;
+ struct reg *reg;
+
+ for (i = 0; VEC_iterate (tdesc_reg_p, reg_defs, i, reg); i++)
+ xfree (reg);
+ VEC_free (tdesc_reg_p, reg_defs);
+ }
#endif
};
#include "features/i386/32bit-mpx.c"
#include "features/i386/32bit-avx512.c"
#include "features/i386/32bit-pkeys.c"
+#include "target-descriptions.h"
/* Return non-zero, when the register is in the corresponding register
group. Put the LINUX_ORIG_EAX register in the system group. */
echo "{"
echo " static struct target_desc tdesc_${name}_s;"
echo " struct target_desc *result = &tdesc_${name}_s;"
- echo " memset (result, 0, sizeof (*result));"
continue
elif test "${type}" = "xmltarget"; then
echo "$0: $1 does not specify \`\`name''." 1>&2
exit 1
else
- echo " {struct reg *reg = XCNEW (struct reg);"
- echo " reg->name = \"${entry}\";"
- echo " reg->offset = ${offset};"
- echo " reg->size = ${type};"
- echo " VEC_safe_push (tdesc_reg_p, result->reg_defs, reg);"
- echo " };"
+ echo " tdesc_create_reg ((struct tdesc_feature *) result, \"${entry}\","
+ echo " 0, 0, NULL, ${type}, NULL);"
+
offset=`expr ${offset} + ${type}`
i=`expr $i + 1`
fi
gdb_assert_not_reached ("bad predefined tdesc type");
}
-/* Return the type associated with ID in the context of FEATURE, or
- NULL if none. */
+/* See arch/tdesc.h. */
struct tdesc_type *
tdesc_named_type (const struct tdesc_feature *feature, const char *id)
}
\f
+/* See arch/tdesc.h. */
+
void
tdesc_create_reg (struct tdesc_feature *feature, const char *name,
int regnum, int save_restore, const char *group,
VEC_safe_push (tdesc_reg_p, feature->registers, reg);
}
+/* See arch/tdesc.h. */
+
struct tdesc_type *
tdesc_create_vector (struct tdesc_feature *feature, const char *name,
struct tdesc_type *field_type, int count)
return type;
}
+/* See arch/tdesc.h. */
+
struct tdesc_type *
tdesc_create_struct (struct tdesc_feature *feature, const char *name)
{
return 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. */
+/* See arch/tdesc.h. */
void
tdesc_set_struct_size (struct tdesc_type *type, int size)
type->u.u.size = size;
}
+/* See arch/tdesc.h. */
+
struct tdesc_type *
tdesc_create_union (struct tdesc_feature *feature, const char *name)
{
return type;
}
+/* See arch/tdesc.h. */
+
struct tdesc_type *
tdesc_create_flags (struct tdesc_feature *feature, const char *name,
int size)
return type;
}
-/* Add a new field to TYPE. */
+/* See arch/tdesc.h. */
void
tdesc_add_field (struct tdesc_type *type, const char *field_name,
VEC_safe_push (tdesc_type_field, type->u.u.fields, &f);
}
-/* Add a new typed bitfield to TYPE. */
-
void
tdesc_add_typed_bitfield (struct tdesc_type *type, const char *field_name,
int start, int end, struct tdesc_type *field_type)
VEC_safe_push (tdesc_type_field, type->u.u.fields, &f);
}
-/* Add a new untyped bitfield to TYPE.
- Untyped bitfields become either uint32 or uint64 depending on the size
- of the underlying type. */
+/* See arch/tdesc.h. */
void
tdesc_add_bitfield (struct tdesc_type *type, const char *field_name,
tdesc_add_typed_bitfield (type, field_name, start, end, field_type);
}
-/* A flag is just a typed(bool) single-bit bitfield.
- This function is kept to minimize changes in generated files. */
+/* See arch/tdesc.h. */
void
tdesc_add_flag (struct tdesc_type *type, int start,
VEC_safe_push (tdesc_type_field, type->u.u.fields, &f);
}
+/* See arch/tdesc.h. */
+
struct tdesc_feature *
tdesc_create_feature (struct target_desc *tdesc, const char *name)
{
printf_unfiltered (" Original: %s */\n\n",
lbasename (m_filename_after_features.c_str ()));
- printf_unfiltered ("#include \"target-descriptions.h\"\n");
+ printf_unfiltered ("#include \"arch/tdesc.h\"\n");
printf_unfiltered ("\n");
}
#ifndef TARGET_DESCRIPTIONS_H
#define TARGET_DESCRIPTIONS_H 1
+#include "arch/tdesc.h"
-struct tdesc_feature;
struct tdesc_arch_data;
-struct tdesc_type;
-struct tdesc_reg;
-struct target_desc;
struct target_ops;
-struct target_desc;
/* An inferior's target description info is stored in this opaque
object. There's one such object per inferior. */
struct target_desc_info;
const char *tdesc_feature_name (const struct tdesc_feature *feature);
-/* 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 name of register REGNO, from the target description or
from an architecture-provided pseudo_register_name method. */
const char *key, const char *value);
void tdesc_add_compatible (struct target_desc *,
const struct bfd_arch_info *);
-
-struct tdesc_feature *tdesc_create_feature (struct target_desc *tdesc,
- const char *name);
-struct tdesc_type *tdesc_create_vector (struct tdesc_feature *feature,
- const char *name,
- struct tdesc_type *field_type,
- int count);
-struct tdesc_type *tdesc_create_struct (struct tdesc_feature *feature,
- const char *name);
-void tdesc_set_struct_size (struct tdesc_type *type, int size);
-struct tdesc_type *tdesc_create_union (struct tdesc_feature *feature,
- const char *name);
-struct tdesc_type *tdesc_create_flags (struct tdesc_feature *feature,
- const char *name,
- int size);
struct tdesc_type *tdesc_create_enum (struct tdesc_feature *feature,
const char *name,
int size);
-void tdesc_add_field (struct tdesc_type *type, const char *field_name,
- struct tdesc_type *field_type);
void tdesc_add_typed_bitfield (struct tdesc_type *type, const char *field_name,
int start, int end,
struct tdesc_type *field_type);
-void tdesc_add_bitfield (struct tdesc_type *type, const char *field_name,
- int start, int end);
-void tdesc_add_flag (struct tdesc_type *type, int start,
- const char *flag_name);
void tdesc_add_enum_value (struct tdesc_type *type, int value,
const char *name);
-void tdesc_create_reg (struct tdesc_feature *feature, const char *name,
- int regnum, int save_restore, const char *group,
- int bitsize, const char *type);
#if GDB_SELF_TEST
namespace selftests {