binutils-gdb/gdb/arch/tdesc.h
Yao Qi 5f035c0716 Share i386-linux target description between GDB and GDBserver
The code on creating i386-linux target descriptions are quite similar
between GDB and GDBserver, so this patch moves them into a shared file
arch/i386.c.  I didn't name it as i386-linux.c, because I want to reuse it
to create other i386 non-linux target descriptions later.

gdb:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (ALL_TARGET_OBS): Add i386.o.
	(SFILES): Add arch/i386.c.
	(HFILES_NO_SRCDIR): Add arch/i386.h.
	* arch/i386.c: New file.
	* arch/i386.h: New file.
	* arch/tdesc.h (allocate_target_description): Declare.
	(set_tdesc_architecture): Declare.
	(set_tdesc_osabi): Declare.
	* configure.tgt (i[34567]86-*-linux*): Add i386.o.
	* i386-linux-tdep.c: Don't include ../features/i386/32bit-XXX.c.
	include arch/i386.h.
	(i386_linux_read_description): Remove code and call
	i386_create_target_description.
	(set_tdesc_architecture): New function.
	(set_tdesc_osabi): New function.
	* target-descriptions.h (allocate_target_description): Remove.

gdb/gdbserver:

2017-09-05  Yao Qi  <yao.qi@linaro.org>

	* Makefile.in (arch-i386.o): New rule.
	* configure.srv (i[34567]86-*-linux*): Add arch-i386.o.
	(x86_64-*-linux*): Likewise.
	* linux-x86-tdesc.c: Don't include ../features/i386/32bit-XXX.c,
	include arch/i386.h.
	(i386_linux_read_description): Remove code and call
	i386_create_target_description.
	* tdesc.c (allocate_target_description): New function.
	* tdesc.h (set_tdesc_architecture): Remove declaration.
	(set_tdesc_osabi): Likewise.
2017-09-05 09:54:53 +01:00

93 lines
3.4 KiB
C

/* 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 */