/* Target description support for GDB.
- Copyright (C) 2006-2012 Free Software Foundation, Inc.
+ Copyright (C) 2006-2015 Free Software Foundation, Inc.
Contributed by CodeSourcery.
#include "xml-tdesc.h"
#include "osabi.h"
-#include "gdb_assert.h"
#include "gdb_obstack.h"
#include "hashtab.h"
#include "inferior.h"
} tdesc_type_flag;
DEF_VEC_O(tdesc_type_flag);
+enum tdesc_type_kind
+{
+ /* Predefined types. */
+ TDESC_TYPE_INT8,
+ TDESC_TYPE_INT16,
+ TDESC_TYPE_INT32,
+ TDESC_TYPE_INT64,
+ TDESC_TYPE_INT128,
+ TDESC_TYPE_UINT8,
+ TDESC_TYPE_UINT16,
+ TDESC_TYPE_UINT32,
+ TDESC_TYPE_UINT64,
+ TDESC_TYPE_UINT128,
+ TDESC_TYPE_CODE_PTR,
+ TDESC_TYPE_DATA_PTR,
+ TDESC_TYPE_IEEE_SINGLE,
+ TDESC_TYPE_IEEE_DOUBLE,
+ TDESC_TYPE_ARM_FPA_EXT,
+ TDESC_TYPE_I387_EXT,
+
+ /* Types defined by a target feature. */
+ TDESC_TYPE_VECTOR,
+ TDESC_TYPE_STRUCT,
+ TDESC_TYPE_UNION,
+ TDESC_TYPE_FLAGS
+};
+
typedef struct tdesc_type
{
/* The name of this type. */
char *name;
/* Identify the kind of this type. */
- enum
- {
- /* Predefined types. */
- TDESC_TYPE_INT8,
- TDESC_TYPE_INT16,
- TDESC_TYPE_INT32,
- TDESC_TYPE_INT64,
- TDESC_TYPE_INT128,
- TDESC_TYPE_UINT8,
- TDESC_TYPE_UINT16,
- TDESC_TYPE_UINT32,
- TDESC_TYPE_UINT64,
- TDESC_TYPE_UINT128,
- TDESC_TYPE_CODE_PTR,
- TDESC_TYPE_DATA_PTR,
- TDESC_TYPE_IEEE_SINGLE,
- TDESC_TYPE_IEEE_DOUBLE,
- TDESC_TYPE_ARM_FPA_EXT,
- TDESC_TYPE_I387_EXT,
-
- /* Types defined by a target feature. */
- TDESC_TYPE_VECTOR,
- TDESC_TYPE_STRUCT,
- TDESC_TYPE_UNION,
- TDESC_TYPE_FLAGS
- } kind;
+ enum tdesc_type_kind kind;
/* Kind-specific data. */
union
struct tdesc_arch_data *
tdesc_data_alloc (void)
{
- return XZALLOC (struct tdesc_arch_data);
+ return XCNEW (struct tdesc_arch_data);
}
/* Free something allocated by tdesc_data_alloc, if it is not going
int regnum, int save_restore, const char *group,
int bitsize, const char *type)
{
- struct tdesc_reg *reg = XZALLOC (struct tdesc_reg);
+ struct tdesc_reg *reg = XCNEW (struct tdesc_reg);
reg->name = xstrdup (name);
reg->target_regnum = regnum;
tdesc_create_vector (struct tdesc_feature *feature, const char *name,
struct tdesc_type *field_type, int count)
{
- struct tdesc_type *type = XZALLOC (struct tdesc_type);
+ struct tdesc_type *type = XCNEW (struct tdesc_type);
type->name = xstrdup (name);
type->kind = TDESC_TYPE_VECTOR;
struct tdesc_type *
tdesc_create_struct (struct tdesc_feature *feature, const char *name)
{
- struct tdesc_type *type = XZALLOC (struct tdesc_type);
+ struct tdesc_type *type = XCNEW (struct tdesc_type);
type->name = xstrdup (name);
type->kind = TDESC_TYPE_STRUCT;
struct tdesc_type *
tdesc_create_union (struct tdesc_feature *feature, const char *name)
{
- struct tdesc_type *type = XZALLOC (struct tdesc_type);
+ struct tdesc_type *type = XCNEW (struct tdesc_type);
type->name = xstrdup (name);
type->kind = TDESC_TYPE_UNION;
tdesc_create_flags (struct tdesc_feature *feature, const char *name,
LONGEST size)
{
- struct tdesc_type *type = XZALLOC (struct tdesc_type);
+ struct tdesc_type *type = XCNEW (struct tdesc_type);
type->name = xstrdup (name);
type->kind = TDESC_TYPE_FLAGS;
struct tdesc_feature *
tdesc_create_feature (struct target_desc *tdesc, const char *name)
{
- struct tdesc_feature *new_feature = XZALLOC (struct tdesc_feature);
+ struct tdesc_feature *new_feature = XCNEW (struct tdesc_feature);
new_feature->name = xstrdup (name);
struct target_desc *
allocate_target_description (void)
{
- return XZALLOC (struct target_desc);
+ return XCNEW (struct target_desc);
}
static void
static void
set_tdesc_cmd (char *args, int from_tty)
{
- help_list (tdesc_set_cmdlist, "set tdesc ", -1, gdb_stdout);
+ help_list (tdesc_set_cmdlist, "set tdesc ", all_commands, gdb_stdout);
}
static void
static void
unset_tdesc_cmd (char *args, int from_tty)
{
- help_list (tdesc_unset_cmdlist, "unset tdesc ", -1, gdb_stdout);
+ help_list (tdesc_unset_cmdlist, "unset tdesc ", all_commands, gdb_stdout);
}
static void
printed_field_type = 1;
}
- if (type->kind == TDESC_TYPE_UNION
+ if ((type->kind == TDESC_TYPE_UNION
+ || type->kind == TDESC_TYPE_STRUCT)
&& VEC_length (tdesc_type_field, type->u.u.fields) > 0)
{
printf_unfiltered (" struct tdesc_type *type;\n");
(" tdesc_create_vector (feature, \"%s\", field_type, %d);\n",
type->name, type->u.v.count);
break;
+ case TDESC_TYPE_STRUCT:
+ printf_unfiltered
+ (" type = tdesc_create_struct (feature, \"%s\");\n",
+ type->name);
+ if (type->u.u.size != 0)
+ printf_unfiltered
+ (" tdesc_set_struct_size (type, %s);\n",
+ plongest (type->u.u.size));
+ for (ix3 = 0;
+ VEC_iterate (tdesc_type_field, type->u.u.fields, ix3, f);
+ ix3++)
+ {
+ /* Going first for implicitly sized types, else part handles
+ bitfields. As reported on xml-tdesc.c implicitly sized types
+ cannot contain a bitfield. */
+ if (f->type != NULL)
+ {
+ printf_unfiltered
+ (" field_type = tdesc_named_type (feature, \"%s\");\n",
+ f->type->name);
+ printf_unfiltered
+ (" tdesc_add_field (type, \"%s\", field_type);\n",
+ f->name);
+ }
+ else
+ printf_unfiltered
+ (" tdesc_add_bitfield (type, \"%s\", %d, %d);\n",
+ f->name, f->start, f->end);
+ }
+ break;
case TDESC_TYPE_UNION:
printf_unfiltered
(" type = tdesc_create_union (feature, \"%s\");\n",