2017-09-05 16:54:53 +08:00
|
|
|
/* 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;
|
|
|
|
|
2017-09-05 16:54:53 +08:00
|
|
|
/* 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);
|
|
|
|
|
2017-09-05 16:54:53 +08:00
|
|
|
/* 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,
|
Dynamically composite xml in reply to GDB
GDBserver still uses pre-generated target descriptions in order to
reply to GDB's query on target description (see xml-builtin-generated.c
in GDBserver build directory). This patch teaches GDBserver to
create XML contents according to the target descriptions rather than
using pre-generated ones.
First, change target feature c files to pass the feature xml file
name to tdesc_create_feature, so that target description in GDBserver
can record them, and create XML contents from these features in
buffer, like
...
<xi:include href="$FEATURE1_XML_NAME"/>
<xi:include href="$FEATURE2_XML_NAME"/>
...
and send this buffer back to GDB.
Note that this patch reuses target_desc.xmltarget a little bit, which is
to hold the XML contents dynamically generated in tdesc_get_features_xml.
However, it is not xfree'ed in ~target_desc, because we can't tell it is
from xstrdup or a literal string. Since we don't delete target_desc,
there is no memory leak yet. After we change all target descriptions to
the new style, target_desc.xmltarget is from xstrdup, then, we can safely
xfree it in ~target_desc.
gdb:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* arch/tdesc.h (tdesc_create_feature): Add an argument xml.
* target-descriptions.c (tdesc_create_feature): Likewise, and
adjust code.
* 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.
gdb/gdbserver:
2017-09-05 Yao Qi <yao.qi@linaro.org>
* linux-x86-tdesc.c: Don't include <inttypes.h>.
(i386_linux_read_description) [!IN_PROCESS_AGENT]: Call
set_tdesc_architecture and set_tdesc_osabi. Remove code setting
.xmltarget.
* server.c (get_features_xml): Call tdesc_get_features_xml.
* tdesc.c (set_tdesc_architecture): New function.
(set_tdesc_osabi): New function.
(tdesc_get_features_xml): New function.
(tdesc_create_feature): Add an argument.
* tdesc.h (struct target_desc) <features>: New field.
<arch, osabi>: New field.
(~target_desc): xfree features, arch, and osabi.
(target_desc::oerator==): Don't compare .xmltarget.
[!IN_PROCESS_AGENT] (set_tdesc_architecture): Declare.
(set_tdesc_osabi): Likewise.
(tdesc_get_features_xml): Likewise.
2017-09-05 16:54:53 +08:00
|
|
|
const char *name,
|
|
|
|
const char *xml = nullptr);
|
|
|
|
|
2017-09-05 16:54:53 +08:00
|
|
|
|
|
|
|
/* 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 */
|